aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/lib.go
AgeCommit message (Collapse)Author
2021-07-14[dev.boringcrypto.go1.15] all: merge go1.15.14 into dev.boringcrypto.go1.15Filippo Valsorda
Change-Id: Ia5ae002730c2c0e6bea5e9a10bf335af3ef23e23
2021-06-10[release-branch.go1.15] cmd/link: pass arch-specific flags to external ↵Cherry Zhang
linker when testing supported flag When testing if a flag (e.g. "-no-pie") is supported by the external linker, pass arch-specific flags (like "-marm"). In particular, on the ARM builder, if CGO_LDFLAGS=-march=armv6 is set, the C toolchain fails to build if -marm is not passed. # cc -march=armv6 1.c 1.c: In function 'main': 1.c:3:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI int main() { ^~~ This makes the Go linker think "-no-pie" is not supported when it actually is. Passing -marm makes it work. Fixes #46684. Change-Id: I4e8b71f08818993cbbcb2494b310c68d812d6b50 Reviewed-on: https://go-review.googlesource.com/c/go/+/278592 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> (cherry picked from commit a318d56c1e6e89996a3852a780f45c792d860d64) Reviewed-on: https://go-review.googlesource.com/c/go/+/326711 Run-TryBot: Carlos Amedee <carlos@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-04-21[dev.boringcrypto.go1.15] all: merge go1.15.11 into dev.boringcrypto.go1.15Filippo Valsorda
Change-Id: I964039a36b7c2c6ef217717755ad78595a3b71fb
2021-03-31[release-branch.go1.15] cmd/link: avoid exporting all symbols on windows ↵Quim Muntal
buildmode=pie Marking one functions with __declspec(dllexport) forces mingw to create .reloc section without having to export all symbols. See https://insights.sei.cmu.edu/cert/2018/08/when-aslr-is-not-really-aslr---the-case-of-incorrect-assumptions-and-bad-defaults.html for more info. This change cuts 73kb of a "hello world" pie binary. Updates #6853. Updates #40795. Fixes #43592. Change-Id: I3cc57c3b64f61187550bc8751dfa085f106c8475 Reviewed-on: https://go-review.googlesource.com/c/go/+/264459 Trust: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/300692 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: David Chase <drchase@google.com>
2021-01-20[dev.boringcrypto.go1.15] all: merge go1.15.7 into dev.boringcrypto.go1.15Roland Shoemaker
Change-Id: I2d5a481ef3862f558467c6d71f46e483cc50e1fe
2021-01-16[release-branch.go1.15-security] all: introduce and use internal/execabsRoland Shoemaker
Introduces a wrapper around os/exec, internal/execabs, for use in all commands. This wrapper prevents exec.LookPath and exec.Command from running executables in the current directory. All imports of os/exec in non-test files in cmd/ are replaced with imports of internal/execabs. This issue was reported by RyotaK. Fixes CVE-2021-3115 Change-Id: I0423451a6e27ec1e1d6f3fe929ab1ef69145c08f Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955304 Reviewed-by: Russ Cox <rsc@google.com> Reviewed-by: Katie Hockman <katiehockman@google.com> (cherry picked from commit 44f09a6990ccf4db601cbf8208c89ac4e888f884) Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955308
2020-08-17[dev.boringcrypto.go1.15] all: merge go1.15 into dev.boringcrypto.go1.15Filippo Valsorda
Change-Id: I6eecfb4730f88ea8546ec88afdffe33f45dedac9
2020-07-27cmd/link: don't mark shared library symbols reachable unconditionallyCherry Zhang
During the transitioning period, we mark symbols from Go shared libraries reachable unconditionally. That might be useful when there was still a large portion of the linker using sym.Symbols, and only reachable symbols were converted to sym.Symbols. Marking them reachable brings them to the dynamic symbol table, even if they are not needed, increased the binary size unexpectedly. That time has passed. Now we largely operate on loader symbols, and it is not needed to mark them reachable anymore. Fixes #40416. Change-Id: I1e2bdb93a960ba7dc96575fabe15af93d8e95329 Reviewed-on: https://go-review.googlesource.com/c/go/+/244839 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-07-09[dev.boringcrypto] all: merge master into dev.boringcryptoDmitri Shuralyov
Change-Id: I948e086e11e1da571e2be23bb08a7bbd6618dc2f
2020-07-01cmd/link: fix GC data reading from shared library (attempt 2)Cherry Zhang
When linking against a Go shared library, when a global variable in the main module has a type defined in the shared library, the linker needs to pull the GC data from the shared library to build the GC program for the global variable. Currently, this fails silently, as the shared library file is closed too early and the read failed (with no error check), causing a zero GC map emitted for the variable, which in turn causes the runtime to treat the variable as pointerless. For now, fix this by keeping the file open. In the future we may want to use mmap to read from the shared library instead. Also add error checking. And fix a (mostly harmless) mistake in size caluculation. Also remove an erroneous condition for ARM64. ARM64 used to have a special case to get the addend from the relocation on the gcdata field. That was removed, but the new code accidentally returned 0 unconditionally. It's no longer necessary to have any special case, since the addend is now applied directly to the gcdata field on ARM64, like on all the other platforms. Fixes #39927. This is the second attempt of CL 240462. And this reverts CL 240616. Change-Id: I01c82422b9f67e872d833336885935bc509bc91b Reviewed-on: https://go-review.googlesource.com/c/go/+/240621 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-07-01cmd/link: mark special symbols reachableCherry Zhang
The special symbols are linker-created symbols for special purposes, therefore reachable (otherwise the linker won't create them). Mark them so, so they get converted to sym.Symbols when we convert to old symbol representation. In particular, the failure for building shared library on PPC64 is due to .TOC. symbol not being converted to sym.Symbol, but referenced in addmoduledata. Change-Id: Iaf5d145ffa5d15122e86a6e6983514e56dd5d456 Reviewed-on: https://go-review.googlesource.com/c/go/+/240620 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-06-30Revert "cmd/link: fix GC data reading from shared library"Cherry Zhang
This reverts CL 240462. Reason for revert: test fails on PPC64LE. Updates #39927. Change-Id: I4f14fd0c36e604a80ae9f2f86d1e643e28945e93 Reviewed-on: https://go-review.googlesource.com/c/go/+/240616 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-06-30cmd/link: fix GC data reading from shared libraryCherry Zhang
When linking against a Go shared library, when a global variable in the main module has a type defined in the shared library, the linker needs to pull the GC data from the shared library to build the GC program for the global variable. Currently, this fails silently, as the shared library file is closed too early and the read failed (with no error check), causing a zero GC map emitted for the variable, which in turn causes the runtime to treat the variable as pointerless. For now, fix this by keeping the file open. In the future we may want to use mmap to read from the shared library instead. Also add error checking. And fix a (mostly harmless) mistake in size caluculation. Also remove an erroneous condition for ARM64. ARM64 used to have a special case to get the addend from the relocation on the gcdata field. That was removed, but the new code accidentally returned 0 unconditionally. It's no longer necessary to have any special case, since the addend is now applied directly to the gcdata field on ARM64, like on all the other platforms. Fixes #39927. Change-Id: Iecd32315b326c7059587fdc190e2fa99426e497e Reviewed-on: https://go-review.googlesource.com/c/go/+/240462 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Austin Clements <austin@google.com>
2020-06-04all: fix dead links to inferno-os bitbucket repositoryTobias Klauser
Generated using: perl -i -npe 's#inferno-os/src/default#inferno-os/src/master#' $(git grep -l "inferno-os/src/default" | grep -v vendor) Change-Id: I4b6443bd09a8ea4c8aaeb40a1c73520d1f7ca648 Reviewed-on: https://go-review.googlesource.com/c/go/+/235821 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com>
2020-05-26cmd/link/internal/ld/lib.go: use lld on AndroidPaul D. Weber
Set linker explicitly to lld because the default does not work on NDK versions r19c, r20, r20b and r21. NDK 18b (or earlier) based builds will need to specify -fuse-ld=gold. Fixes #38838 Change-Id: Ib75f71fb9896b843910f41bd12aa1e36868fa9b3 GitHub-Last-Rev: eeaa171604b59d8ad3d86944ebf21ee758e92f95 GitHub-Pull-Request: golang/go#39217 Reviewed-on: https://go-review.googlesource.com/c/go/+/235017 Reviewed-by: Elias Naur <mail@eliasnaur.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-05-25cmd/link/internal/ld: consider alternative linkers in linkerFlagSupportedElias Naur
CL 235017 is about to change the default Android linker to lld. lld doesn't support the --compress-debug-sections=zlib-gnu flag, but linkerFlagSupported doesn't take any alternative linkers specified with -fuse-ld into account. Updates #38838 Change-Id: I5f7422c06d40dedde2e4b070fc48398e8f822190 Reviewed-on: https://go-review.googlesource.com/c/go/+/235157 Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-07[dev.boringcrypto] all: merge master into dev.boringcryptoDmitri Shuralyov
Change-Id: Idd59c37d2fd759b0f73d2ee01b30f72ef4e9aee8
2020-05-01[dev.link] cmd/link: directly use loader.ExtReloc in ELF relocation generationCherry Zhang
Convert the part that uses relocations to use loader.ExtReloc directly. It still uses sym.Symbols for now, but not sym.Relocs. This reduces some memory usage: linking cmd/compile with external linking, name old allocs/op new allocs/op delta Loadlibfull_GC 52.2MB ± 0% 13.9MB ± 0% -73.40% (p=0.008 n=5+5) name old live-B new live-B delta Loadlibfull_GC 75.5M ± 0% 61.9M ± 0% -18.02% (p=0.008 n=5+5) Change-Id: I317ecbf516063c42b255b2caba310ea6281342d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/231319 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-30[dev.link] cmd/link: pass reloc by value to Adddynrel2Cherry Zhang
Adddynrel2 is a function pointer. In dynrelocsym we pass &r to it, which will cause r to escape. Pass it by value instead. Linking cmd/compile, name old alloc/op new alloc/op delta Dodata_GC 15.8MB ± 0% 5.9MB ± 0% -62.55% (p=0.008 n=5+5) Change-Id: Ib86005d1026ebaca57777b27ead037e613585f44 Reviewed-on: https://go-review.googlesource.com/c/go/+/231045 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-30[dev.link] cmd/link: unescape relocs passed to Archreloc2Cherry Zhang
Archreloc2 is a function pointer. It will escape its pointer arguments. In relocsym, as we pass &r and &rr to Archreloc2, it causes them to escape, even if Archreloc2 is not actually called. Instead, pass r by value. loader.Reloc2 is a small structure which is intended to be passed by value. For rr, as Archreloc2 will likely return true, we speculatively add it to extRelocs slice and use that space to pass to Archreloc2. Linking cmd/compile, name old alloc/op new alloc/op delta Dwarfcompress_GC 110MB ± 0% 24MB ± 0% -78.34% (p=0.008 n=5+5) Reloc_GC 24.6MB ± 0% 0.0MB ± 0% -100.00% (p=0.029 n=4+4) Linking cmd/compile using external linking name old alloc/op new alloc/op delta Reloc_GC 152MB ± 0% 36MB ± 0% -76.07% (p=0.008 n=5+5) Change-Id: I1415479e0c17ea9787f9a62453dce00ad9ea792f Reviewed-on: https://go-review.googlesource.com/c/go/+/231077 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-29[dev.link] cmd/link: add loader.ExtReloc to Archreloc2Jeremy Faller
Non functional, but required by the majority of the architectures. Change-Id: I57601016c28ce665a9d434e283a1db8bded9b133 Reviewed-on: https://go-review.googlesource.com/c/go/+/230858 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-29[dev.link] cmd/link: remove Sub field from sym.SymbolThan McIntosh
Remove 'Sub' field from sym.Symbol, replacing uses (those downstream of loadlibfull) with loader method calls. NB: removing the Outer field will have to wait for now; it is accessed in archreloc methods that don't have access to link ctxt or loader currently. Change-Id: I2abe5906fc169c64b2ab7d5ad213619bea5a17c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/230617 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-28[dev.link] cmd/link: add archrelocsym x86 support for loaderJeremy Faller
Change-Id: I34822e5610caf537d62203fb6e0023c382a1e60a Reviewed-on: https://go-review.googlesource.com/c/go/+/230678 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-28[dev.link] cmd/link: convert reloc pass to using the loader when internal ↵Cherry Zhang
linking Only enabled for AMD64 when internal linking for now. Change-Id: I2aa9ee47c0f7413ea7bbcdd31b8317c14220bba3 Reviewed-on: https://go-review.googlesource.com/c/go/+/230302 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-28[dev.link] cmd/link: remove elf sym fields from sym.SymbolThan McIntosh
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[dev.link] cmd/link: remove Gotype and File fields from sym.SymbolThan McIntosh
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[dev.link] cmd/link: tweak genasmsym to eliminate Gotype refThan McIntosh
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[dev.link] cmd/link: write data sections to heap in Asmb on WasmCherry Zhang
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[dev.link] cmd/link: convert dwarfcompress to using the loaderCherry Zhang
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-28Revert "[dev.link] cmd/link: stop overwriting symbol types in loadlibfull"Cherry Zhang
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-27[dev.link] cmd/link: stop overwriting symbol types in loadlibfullCherry Zhang
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[dev.link] cmd/link: remove ctxt.Syms.AllsymCherry Zhang
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-24[dev.link] cmd/link: check fingerprint for index consistencyCherry Zhang
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[dev.link] cmd/link: begin converting dodata() to loader APIsThan McIntosh
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[dev.link] cmd/link: move more error handling into loaderThan McIntosh
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-22[dev.link] cmd/link/internal/loader: preprocess numeric constants earlierThan McIntosh
Change the timing for preprocessing of integer/floating point constant symbols so that we populate them with content at an earlier stage. This is needed to allow them can be picked up by the loader-API version of dodata(). Change-Id: Icf09f4f4b318b4f77e11d4a0f0a9cbecd76a1d6b Reviewed-on: https://go-review.googlesource.com/c/go/+/229438 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-22[dev.link] cmd/link: delete ctxt.ReachparentCherry Zhang
It is no longer needed as we have converted the fieldtrack pass to using the loader. Also free loader.Reachparent after we are done with it. Change-Id: Ibc4b29f282e1e4aea363a1b549755e31f84b0295 Reviewed-on: https://go-review.googlesource.com/c/go/+/229322 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-22[dev.link] cmd/link: reduce memory usage for storing symbol section informationCherry Zhang
Currently, we use a dense array to store symbol's sections. The array element is a *sym.Section, which takes 8 bytes per symbol on a 64-bit machine. And the array is created upfront. To reduce memory usage, use a 16-bit index for sections, so we store 2 bytes per symbol. The array is pointerless, reducing GC work. Also create the array lazily. This reduces some memory usage: linking cmd/compile, name old alloc/op new alloc/op delta Loadlib_GC 42.1MB ± 0% 36.2MB ± 0% -14.01% (p=0.008 n=5+5) name old live-B new live-B delta Loadlib_GC 16.8M ± 0% 15.4M ± 0% -8.36% (p=0.008 n=5+5) Archive_GC 98.2M ± 0% 97.2M ± 0% -1.02% (p=0.008 n=5+5) # at the end Change-Id: If8c41eded8859660bca648c5e6fdf5830810fbf6 Reviewed-on: https://go-review.googlesource.com/c/go/+/229306 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-21[dev.link] cmd/link: convert symtab pass to new styleCherry Zhang
This is more or less a direct translation, to get things going. There are more things we can do to make it better, especially on the handling of container symbols. Change-Id: I11a0087e402be8d42b9d06869385ead531755272 Reviewed-on: https://go-review.googlesource.com/c/go/+/229125 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-20[dev.link] cmd/link: revise representation of dwarfpThan McIntosh
Change linker DWARF generation to move away from emitting a single giant list of DWARF symbols, and instead emit a list of descriptors, with each descriptor holding the symbols for a specific DWARF section. While placing all DWARF symbols in a single lists does come in handy in certain instances, it also creates a lot of confusion and weird code in other cases, specifically where we want to perform operations on a section-by-section basis (resulting in code that tries to re-discover section boundaries by walking/inspecting the list). Change-Id: I4dac81bd38cba903c9fd7004d613597e76dfb77a Reviewed-on: https://go-review.googlesource.com/c/go/+/228780 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-20[dev.link] cmd/link: rename deadcode2 to deadcodeJeremy Faller
deadcode's been completely replaced. Make its death official. Change-Id: I85f1e3968463f216b8bce2fb7217c3b51641939f Reviewed-on: https://go-review.googlesource.com/c/go/+/229002 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-14[dev.link] cmd/link: hoist dwarfGenerateDebugSyms out of dodata()Than McIntosh
Hoist dwarfGenerateDebugSyms call up out of dodata to before loadlibfull. This required a couple of small tweaks to the loader and to loadlibfull. Change-Id: I48ffb450d2e48b9e55775b73a6debcd27dbb7b9c Reviewed-on: https://go-review.googlesource.com/c/go/+/228221 Run-TryBot: Cherry Zhang <cherryyz@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-13[dev.link] cmd/link: remove symbol.FuncInfoCherry Zhang
It is no longer used. The only remaining use is in generating Plan 9 debug info, which is already not supported. Change-Id: Ia023d6f2fa7d57b97ba861ce464e2eec8ac2d1f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/228142 Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-10[dev.link] all: merge branch 'master' into dev.linkCherry Zhang
Clean merge. Change-Id: Ic3634fa450e42635e2daafb53b7dedc6c954d072
2020-04-10[dev.link] cmd/link: convert pcln linker phase to use loader APIsThan McIntosh
Rework the linker's pcln phase to work with the new loader. As part of this set of changes the handling of "go.file..." symbols has been revised somewhat -- previously they were treated as always live in the loader, and now we no longer do this. The original plan had been to have the new implementation generate nameless "inltree" symbols, however the plan now is to keep them named for now and convert them to nameless in a subsequent patch. Change-Id: If71c93ff1f146dbb63b6ee2546308acdc94b643c Reviewed-on: https://go-review.googlesource.com/c/go/+/227759 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-08[dev.boringcrypto] all: merge master into dev.boringcryptoFilippo Valsorda
Change-Id: I2dcec316fd08d91db4183fb9d3b9afde65cc248f
2020-04-08all: remove scattered remnants of darwin/386Austin Clements
This removes all conditions and conditional code (that I could find) that depended on darwin/386. Fixes #37610. Change-Id: I630d9ea13613fb7c0bcdb981e8367facff250ba0 Reviewed-on: https://go-review.googlesource.com/c/go/+/227582 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-08[dev.link] cmd/link: convert text address assignment to new styleCherry Zhang
Implement text address assignment and trampoline generation using the loader. Note: the trampoline insertion part doesn't actually work. It also needs to propagate Aux symbols for external symbols in LoadFull. But it won't be needed after converting pclntab generation, so I'll leave it out for now. This could break linking large binaries on PPC64 and ARM. Change-Id: Ie46a35b25d7c027983dd877207cfa8f67c32530b Reviewed-on: https://go-review.googlesource.com/c/go/+/227482 Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-08[dev.link] cmd/link: return package path in SymFileCherry Zhang
SymFile, derived from sym.Symbol.File, is supposed to return the package path, instead of the file name (arguably the name is confusing). Make it so, and rename it to SymPkg. Change-Id: I67bcd12f67cea271f2a2ce3c5724e5d228f5b2f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/227481 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-07[dev.link] cmd/link: fix bugs in setArchSymsThan McIntosh
The code in setArchsyms that sets up TOC symbols was buggy; it was kicking in only for aix-ppc64 and not linux-ppc64. These symbols are required for both ABIs, so change the guard in question from "ctx.IsAIX()" to "ctxt.IsPPC64()". Also, the code to create versioned ".TOC." syms was not passing the correct symbol version to the loader (now fixed). Change-Id: I356071e528beadad20f61d067059eaf26f06e06b Reviewed-on: https://go-review.googlesource.com/c/go/+/227257 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>