aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/loader/loader.go
AgeCommit message (Collapse)Author
2021-06-29[release-branch.go1.15] cmd/link: fix handling of dupok mapzero symsThan McIntosh
The compiler machinery that generates "map.zero" symbols marks them as RODATA and DUPOK, which is problematic when a given application has multiple map zero symbols (from different packages) with varying sizes: the dupok path in the loader assumes that if two symbols have the same name, it is safe to pick any of the versions. In the case of map.zero, the link needs to select the largest symbol, not an arbitrary sym. This patch changes the linker's dupok symbol loading path to detect this problem, and in situations where we're loading a dupok symbol whose name is the same as an existing symbol but whose size is large, select the new dup over the old. Note: this fix differs from the one used in 1.16/1.17, which uses content-addressable symbols instead. Fixes #46656. Change-Id: Iabd2feef01d448670ba795c7eaddc48c191ea276 Reviewed-on: https://go-review.googlesource.com/c/go/+/326211 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit aa5540cd82170f82c6fe11511e12de96aa58cbc1) Reviewed-on: https://go-review.googlesource.com/c/go/+/326213
2020-06-08all: avoid awkward wording from CL 236857Russ Cox
CL 236857 removed all uses of whitelist/blacklist, which is great. But it substituted awkward phrasing using allowlist/blocklist, especially as verbs or participles. This CL uses more standard English, like "allow the function" or "blocked functions" instead of "allowlist the function" or "blocklisted functions". Change-Id: I9106a2fdbd62751c4cbda3a77181358a8a6d0f13 Reviewed-on: https://go-review.googlesource.com/c/go/+/236917 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-08all: replace usages of whitelist/blacklist and master/slaveFilippo Valsorda
There's been plenty of discussion on the usage of these terms in tech. I'm not trying to have yet another debate. It's clear that there are people who are hurt by them and who are made to feel unwelcome by their use due not to technical reasons but to their historical and social context. That's simply enough reason to replace them. Anyway, allowlist and blocklist are more self-explanatory than whitelist and blacklist, so this change has negative cost. Didn't change vendored, bundled, and minified files. Nearly all changes are tests or comments, with a couple renames in cmd/link and cmd/oldlink which are extremely safe. This should be fine to land during the freeze without even asking for an exception. Change-Id: I8fc54a3c8f9cc1973b710bbb9558a9e45810b896 Reviewed-on: https://go-review.googlesource.com/c/go/+/236857 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Khosrow Moossavi <khos2ow@gmail.com> Reviewed-by: Leigh McCulloch <leighmcc@gmail.com> Reviewed-by: Urban Ishimwe <urbainishimwe@gmail.com>
2020-06-03cmd/internal/goobj2: add referenced symbol names to object fileCherry Zhang
Currently, for symbols defined in other packages and referenced by index, we don't record its name in the object file, as the linker doesn't need the name, only the index. As a consequence, tools like objdump and nm also don't know the referenced symbol names and cannot dump it properly. This CL adds referenced symbol names to the object file. So the object file is self-contained. And tools can retrieve referenced symbol names properly. Tools now should work as good for new object files as for old object files. Fixes #38875. Change-Id: I16c685c1fd83273ab1faef474e19acf4af46396f Reviewed-on: https://go-review.googlesource.com/c/go/+/236168 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-15cmd/link: detect trampoline of deferreturn callCherry Zhang
The runtime needs to find the PC of the deferreturn call in a few places. So for functions that have defer, we record the PC of deferreturn call in its funcdata. For very large binaries, the deferreturn call could be made through a trampoline. The current code of finding deferreturn PC fails in this case. This CL handles the trampoline as well. Fixes #39049. Change-Id: I929be54d6ae436f5294013793217dc2a35f080d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/234105 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-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-05-01[dev.link] cmd/link: drop fields of external symbols after LoadFullCherry Zhang
Free some memory. Linking cmd/compile with external linking, name old live-B new live-B delta Loadlibfull_GC 55.3M ± 0% 52.2M ± 0% -5.50% (p=0.008 n=5+5) Change-Id: Ib8de2e61f2b012efaf6bdd98f9e5c56a19910b47 Reviewed-on: https://go-review.googlesource.com/c/go/+/231224 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-01[dev.link] cmd/link: batch allocations when converting external relocationsCherry Zhang
Change-Id: Iad81cb159e46f694a03d58892ca7dfde3ee3095a Reviewed-on: https://go-review.googlesource.com/c/go/+/231219 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-05-01[dev.link] cmd/link/internal/loader: change storage mechanism for sym alignmentThan McIntosh
Switch the storage mechanism for symbol alignment away from a map and to a slice of uint8 values per symbol, where value K indicates alignment 2^K. Intended to help speed up alignment get/set in dodata. Change-Id: I26416e455c808f697dd0d7f6d2582247ee5c5b40 Reviewed-on: https://go-review.googlesource.com/c/go/+/231220 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-30[dev.link] cmd/link: use more compact representation for external relocationsCherry Zhang
Currently, for external relocations, the ExtReloc structure contains all the fields of the relocation. In fact, many of the fields are the same with the original relocation. So, instead, we can just use an index to reference the original relocation and not expand the fields. There is one place where we modify relocation type: changing R_DWARFSECTREF to R_ADDR. Get away with it by changing downstreams. It also makes it easier to retrieve the reloc variant. This reduces some allocation. Linking cmd/compile with external linking, name old alloc/op new alloc/op delta Reloc_GC 34.1MB ± 0% 22.7MB ± 0% -33.30% (p=0.000 n=5+4) Change-Id: Id08a89ed2aee705296886d3b95014b806a0d55cf Reviewed-on: https://go-review.googlesource.com/c/go/+/231217 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: fold zero symbol check into ResolveABIAliasCherry Zhang
We call (or will call) ResolveABIAlias in many places. Doing zero symbol check everytime is annoying. Fold the condition into ResolveABIAlias. Change-Id: I10485fe83b9cce2d19b6bd17dc42176f72dae48b Reviewed-on: https://go-review.googlesource.com/c/go/+/231046 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: remove sym.Symbols.NewsymCherry Zhang
No longer needed. Change-Id: If259a956bc8edb2eb94583b06840b52344cb84be Reviewed-on: https://go-review.googlesource.com/c/go/+/231037 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-29[dev.link] cmd/link: free compressed symbols after dwarfcompressCherry Zhang
Once the symbol is compressed, we will not need the uncompressed symbol content. Free its memory. Linking cmd/compile, name old live-B new live-B delta Dwarfcompress_GC 42.7M ± 0% 37.9M ± 0% -11.31% (p=0.008 n=5+5) Change-Id: Ib6cc73832946d158ff4f5b4f31be9c35ba7cf103 Reviewed-on: https://go-review.googlesource.com/c/go/+/230859 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: free loader memory after LoadFullCherry Zhang
After LoadFull, we'll be using sym.Symbols mostly. We still need the loader information for symbol index mappings and name lookups, but not much else. Free some memory. Linking cmd/compile, name old time/op new time/op delta Loadlibfull_GC 44.5M ± 0% 35.8M ± 0% -19.66% (p=0.008 n=5+5) Archive_GC 46.4M ± 0% 37.6M ± 0% -18.89% (p=0.008 n=5+5) Linking cmd/compile with external linking, name old time/op new time/op delta Loadlibfull_GC 82.5M ± 0% 57.4M ± 0% -30.41% (p=0.008 n=5+5) Archive_GC 86.8M ± 0% 61.7M ± 0% -28.90% (p=0.008 n=5+5) Change-Id: I6859d488172ef8968918b86de527fbfed6832ebf Reviewed-on: https://go-review.googlesource.com/c/go/+/230300 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-29[dev.link] cmd/link: support external linking in new reloc implementationCherry Zhang
Support external linking for the new reloc pass as well, and enable it on AMD64 and 386. Change-Id: Ia71aec3d7c14e9d661e0748d2e988f29f220d1e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/230308 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-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: 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: convert asmb pass to new styleCherry Zhang
Change-Id: I8675f56a7f7f18653754eb87b95f5a7aec31ad74 Reviewed-on: https://go-review.googlesource.com/c/go/+/229860 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: remove Unit field from sym.SymbolThan McIntosh
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[dev.link] cmd/link/internal/loader: add elf symbol methodsThan McIntosh
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[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: move wavefront past addressJeremy Faller
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-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-27[dev.link] cmd/link: sort DynidSymsCherry Zhang
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-24[dev.link] cmd/link: fix minor error on error reportingCherry Zhang
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[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/internal/goobj2: add index fingerprint to object fileCherry Zhang
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[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-24[dev.link] cmd/link/internal/loader: add SetRelocType symbolbuilder methodThan McIntosh
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[dev.link] cmd/link/internal/loader: fix buglet in section handlingThan McIntosh
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-22[dev.link] cmd/link/internal/loader: fix AttrSubSymbolThan McIntosh
The code that runs as a part of loadlibfull converts the linker's outer/sub state and sets the sym.Symbol AttrSubSymbol if a symbol has both A) an outer sym, and B) is listed as a sub-symbol by some other symbol. Make sure that we have the same logic in the original loader method, since we need to use it as part of dodata() prior to loadlibfull. Change-Id: I200adab741d778a6ba821419e8ea131ad19375bc Reviewed-on: https://go-review.googlesource.com/c/go/+/229440 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
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: 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-16[dev.link] cmd/link: clear lib.Textp2 after useCherry Zhang
lib.Textp2 is used to assemble the global Textp2. It is not used after that point. Free some memory. Slightly reduces allocation: for linking cmd/compile, Linksetup_GC 1.10MB ± 0% 0.84MB ± 0% -23.43% (p=0.008 n=5+5) Change-Id: Iec4572e282655306d5ff3e490f8855d479e45acf Reviewed-on: https://go-review.googlesource.com/c/go/+/228481 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-15[dev.link] cmd/link/internal/loader: remove some unused typesThan McIntosh
The types funcAllocInfo and funcInfoSym are no longer referenced. Fixes #38456. Change-Id: Icd32445f6027429f4a2781554d2086790ebe5daf Reviewed-on: https://go-review.googlesource.com/c/go/+/228318 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
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: stop populating lib/unit.TextpCherry Zhang
lib.Textp was used for text address assignment and trampoline insertion. Now that it has been converted to using the loader, no need to populate lib.Textp. Port the logic of canonicalizing dupok symbol's package to the loader. unit.Textp was used for DWARF generation, which has also been converted to using the loader. Change-Id: I22d4dd30a52a29dd5b1b7b795d43a19f6215e4ac Reviewed-on: https://go-review.googlesource.com/c/go/+/228140 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-13[dev.link] cmd/link: stop loading FuncInfo in LoadFullCherry Zhang
As we have converted the pclntab generation, FuncInfo is not needed after. No need to load it. Change-Id: Idcfe4da44dfc94d8d44509d12179b354a2e295e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/228139 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-13[dev.link] cmd/link/internal/loader: get rid of the AttrContainer loader methodThan McIntosh
Remove the loader's AttrContainer method, since it is no longer needed. All of the code in the linker that used s.Attr.Container() is now upstream of loadlibfull(), and the code in question now uses local bitmaps to keep track of container text symbols as opposed to loader methods. Change-Id: Iae956d24bef2776e181c3b8208476dcb0b9a2916 Reviewed-on: https://go-review.googlesource.com/c/go/+/227959 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-10[dev.link] cmd/link: fix aux symbol handling in FuncdataCherry Zhang
If a Go symbol is cloned to external, we should preserve its Aux symbols for FuncInfo, etc.. We already do this in loader.FuncInfo, but not in FuncInfo.Funcdata. Do it in the latter as well. In fact, since FuncInfo and Funcdata should use the same set of auxs, just record the auxs and reuse. Should fix PPC64 build. Change-Id: Iab9020eaca15d98fe3bb41f50f0d5bdb4999e8c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/227848 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-10[dev.link] cmd/internal/goobj2: remove "2"Cherry Zhang
Rename Sym2 -> Sym Reloc2 -> Reloc Aux2 -> Aux Also the Reader methods. Change-Id: I49f29e2d1cb480f5309e01d7a74b5e0897d826fb Reviewed-on: https://go-review.googlesource.com/c/go/+/227900 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
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-10[dev.link] cmd/link/internal/loader: expand methods for FuncInfoThan McIntosh
Expand the methods for the FuncInfo helper, to support reading the contents of an object file FuncInfo aux symbol using the new style (that is to say, incrementally and without allocating slices to hold the various bits). Change-Id: I953d72c4a53f98c840e6b25b08fd33dc4a833dd5 Reviewed-on: https://go-review.googlesource.com/c/go/+/227585 Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-09[dev.link] cmd/link: convert typelink pass to new styleCherry Zhang
Change-Id: If861409a5cc4e398496199a89498a141f106f44f Reviewed-on: https://go-review.googlesource.com/c/go/+/227762 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@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>