aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/loader
AgeCommit message (Collapse)Author
2020-09-11[dev.link] all: merge branch 'master' into dev.linkCherry Zhang
Clean merge. Change-Id: Ib773b0bc00fd99d494f9331c3613bcc8285e48e3
2020-09-09cmd/link: pre-resolve package referenceCherry Zhang
Pre-resolve package index references, so it doesn't need to do a map lookup in every cross-package symbol reference resolution. It increases the memory usage very slightly (O(# imported packages)). Change-Id: Ia76c97ac51f1c2c2d5ea7ae34853850ec69ef0a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/253604 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-03[dev.link] cmd/link: fix memory growth on dev.linkJeremy Faller
CL 247399 caused memory growth in the linker. Fix this by adjusting how we preallocate the number of symbols we'll need. cmd/compile (Darwin), alloc/op: Loadlib_GC 33.5MB ± 0% 27.3MB ± 0% Change-Id: I34997329ea4412716114df97fc9dad6ad0c171ee Reviewed-on: https://go-review.googlesource.com/c/go/+/249024 Run-TryBot: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-18[dev.link] cmd/{compile,link}: remove pcdata tables from pclntab_oldJeremy Faller
Move the pctables out of pclntab_old. Creates a new generator symbol, runtime.pctab, which holds all the deduplicated pctables. Also, tightens up some of the types in runtime. Darwin, cmd/compile statistics: alloc/op Pclntab_GC 26.4MB ± 0% 13.8MB ± 0% allocs/op Pclntab_GC 89.9k ± 0% 86.4k ± 0% liveB Pclntab_GC 25.5M ± 0% 24.2M ± 0% No significant change in binary size. Change-Id: I1560fd4421f8a210f8d4b508fbc54e1780e338f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/248332 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-08-13[dev.link] cmd/link, cmd/compile: create content addressable pcdata symsJeremy Faller
Switch pcdata over to content addressable symbols. This is the last step before removing these from pclntab_old. No meaningful benchmarks changes come from this work. Change-Id: I3f74f3d6026a278babe437c8010e22992c92bd89 Reviewed-on: https://go-review.googlesource.com/c/go/+/247399 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-08-11[dev.link] cmd: remove "2", another roundCherry Zhang
Rename the goobj2 package to goobj. Change-Id: Iff97b5575cbac45ac44de96b6bd9d555b9a4a12a Reviewed-on: https://go-review.googlesource.com/c/go/+/246444 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-08-10[dev.link] use per package filenames to build pclntabJeremy Faller
In order to prevent renumbering of filenames in pclntab generation, use the per-package file list (previously only used for DWARF generation) as file-indices. This is the largest step to eliminate renumbering of filenames in pclntab. Note, this is probably not the final state of the file table within the object file. In this form, the linker loads all filenames for all objects. I'll move to storing the filenames as regular string symbols,and defaulting all string symbols to using the larger hash value to make generation of pcln simplest, and most memory friendly. Change-Id: I23daafa3f4b4535076e23100200ae0e7163aafe0 Reviewed-on: https://go-review.googlesource.com/c/go/+/245485 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-08-03[dev.link] cmd/compile, cmd/link: generate itablink at link timeCherry Zhang
Currently, at compile time, for each itab symbol, we create an "itablink" symbol which holds solely the address of the itab symbol. At link time, all the itablink symbols are grouped together to form the itablinks slice. This CL removes the itablink symbols, and directly generate the itablinks slice in the linker. This removes a number of symbols, which are dupOK and generally have long names. And also removes a special handling of itablink symbols in the deadcode pass which iterates through all symbols. Change-Id: I475c3c8899e9fbeec9abc7647b1e4a69aa5c3c5a Reviewed-on: https://go-review.googlesource.com/c/go/+/245901 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-08-03[dev.link] cmd/link: drop hash maps after loadingCherry Zhang
The hash maps are used to deduplicate hashed symbols. Once we loaded all the symbols, we no longer need the hash maps. Drop them. Linking cmd/compile, name old live-B new live-B delta Loadlib_GC 13.1M ± 0% 11.3M ± 0% -13.62% (p=0.008 n=5+5) Change-Id: I4bb1f84e1111a56d9e777cd6a68f7d974b60e321 Reviewed-on: https://go-review.googlesource.com/c/go/+/245721 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-08-03[dev.link] cmd/compile, cmd/link: make itab symbols content-addressableCherry Zhang
Extend the content-addressable symbol mechanism to itab symbols. Itab symbols require global uniqueness (as at run time we compare pointers), so it needs to be reliably deduplicated. Currently the content hash depends on symbol name expansion, so we can only do this when all Go packages are built with know package paths. Fall back to checking names if any Go package is built with unknown package path. Change-Id: Icf5e8873755050c20e5fc6549f6de1c883254c89 Reviewed-on: https://go-review.googlesource.com/c/go/+/245719 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-08-03[dev.link] cmd/compile, cmd/link: reference type symbol of defined type by indexCherry Zhang
The type descriptor symbol of a defined (named) type (and pointer to it) is defined only in the package that defines the type. It is not dupOK, unlike other type descriptors. So it can be referenced by index. Currently it is referenced by name for cross-package references, because the index is not exported and so not known to the referencing package. This CL passes the index through the export data, so the symbol can be referenced by index, and does not need to be looked up by name. This also makes such symbol references consistent: it is referenced by index within the defining package and also cross- package, which makes it easier for content hashing (in later CLs). One complication is that we need to set flags on referenced symbols (specifically, the UsedInIface flag). Before, they are non-package refs, which naturally carry flags in the object file. For indexed refs, we currently don't put their flags in the object file. Introduce a new block for this. Change-Id: I8126f8e318ac4e6609eb2ac136201fd6c264c256 Reviewed-on: https://go-review.googlesource.com/c/go/+/245718 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-08-03[dev.link] move FuncID creation into the compiler/assemblerJeremy Faller
Leaving creation of the funcID till the linker requires the linker to load the function and file names into memory. Moving these into the compiler/assembler prevents this. This work is a step towards moving all func metadata into the compiler. Change-Id: Iebffdc5a909adbd03ac263fde3f4c3d492fb1eac Reviewed-on: https://go-review.googlesource.com/c/go/+/244024 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com>
2020-07-31[dev.link] cmd/link: make symbol attribute setting more reliableCherry Zhang
For dupOK symbols, their attributes should be OR'd. Most of the attributes are expected to be set consistently across multiple definitions, but UsedInIface must be OR'd, and for alignment we need to pick the largest one. Currently the attributes are not always OR'd, depending on addSym returning true or false. This doesn't cause any real problem, but it would be a problem if we make type descriptor symbols content-addressable. This CL removes the second result of addSym, and lets preloadSyms always set the attributes. Also removes the alignment handling on addSym, handles it in preloadSyms only. Change-Id: I06b3f0adb733f6681956ea9ef54736baa86ae7bc Reviewed-on: https://go-review.googlesource.com/c/go/+/245720 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-31[dev.link] create runtime.funcnametabJeremy Faller
Move the function names out of runtime.pclntab_old, creating runtime.funcnametab. There is an unfortunate artifact in this change in that calculating the funcID still requires loading the name. Future work will likely pull this out and put it into the object file Funcs. ls -l cmd/compile (darwin): before: 18524016 after: 18519952 The difference in size can be attributed to alignment in pclntab_old. Change-Id: Ibcbb230d4632178f8fcd0667165f5335786381f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/243223 Reviewed-by: Austin Clements <austin@google.com>
2020-07-30[dev.link] cmd/link: add runtime.pcheaderJeremy Faller
As of July 2020, a fair amount of the new linker's live memory, and runtime is spent generating pclntab. In an effort to streamline that code, this change starts breaking up the generation of runtime.pclntab into smaller chunks that can run later in a link. These changes are described in an (as yet not widely distributed) document that lays out an improved format. Largely the work consists of breaking up runtime.pclntab into smaller pieces, stopping much of the data rewriting, and getting runtime.pclntab into a form where we can reason about its size and look to shrink it. This change is the first part of that work -- just pulling out the header, and demonstrating where a majority of that work will be. Change-Id: I65618d0d0c780f7e5977c9df4abdbd1696fedfcb Reviewed-on: https://go-review.googlesource.com/c/go/+/241598 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com>
2020-07-30[dev.link] cmd/link: remove "2", another roundCherry Zhang
Rename Reloc2 to Reloc, At2 to At, Aux2 to Aux. Change-Id: Ic98d83c080e8cd80fbe1837c8f0aa134033508ce Reviewed-on: https://go-review.googlesource.com/c/go/+/245578 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-30[dev.link] cmd/link: remove loader.RelocCherry Zhang
We have Reloc and Reloc2. Reloc2 is the better approach and most code uses Reloc2. There are still uses of Reloc. This CL migrates them to Reloc2, and removes Reloc. Change-Id: Id5f6a6019e1e044add682d05e70ebb1548ec58d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/245577 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-30[dev.link] cmd/link: refactor ExtReloc data structuresCherry Zhang
We used to generate all external relocations in memory, then emit the relocation records at a later pass. The data structures were chosen so that it takes as little memory as possible. Now we just stream out external relocations, and ExtReloc is just a local variable. Change the data structure to avoid repeated read of some fields. Also get rid of ExtRelocView, as it is no longer necessary. Change-Id: I40209bbe4387af231b29788125c3b4ebb0ff4a33 Reviewed-on: https://go-review.googlesource.com/c/go/+/245479 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-24[dev.link] cmd/link: remove non-streaming external relocation codeCherry Zhang
Now we support streaming external relocations everywhere. Change-Id: I8d107c8239fe979bd5410e6a7f3fe471ac3e8b35 Reviewed-on: https://go-review.googlesource.com/c/go/+/244764 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-21[dev.link] cmd/link: remove OutDataCherry Zhang
OutData was used for a symbol to point to its data in the output buffer, in order to apply relocations. Now we fold relocation application to Asmb next to symbol data writing. We can just pass the output data as a local variable. Linking cmd/compile, name old time/op new time/op delta Asmb_GC 19.0ms ±10% 16.6ms ± 9% -12.50% (p=0.032 n=5+5) name old alloc/op new alloc/op delta Asmb_GC 3.78MB ± 0% 0.14MB ± 1% -96.41% (p=0.008 n=5+5) name old live-B new live-B delta Asmb_GC 27.5M ± 0% 23.9M ± 0% -13.24% (p=0.008 n=5+5) Change-Id: Id870a10dce2a0a7447a05029c6d0ab39b47d0a12 Reviewed-on: https://go-review.googlesource.com/c/go/+/244017 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-21[dev.link] cmd/link: fix hash collision checkCherry Zhang
For content-addressable symbols, we build its content hash based on the symbol data and relocations. When the compiler builds the symbol data, it may not always include the trailing zeros, e.g. the data of [10]int64{1,2,3} is only the first 24 bytes. Therefore, we may end up with symbols with the same contents (thus same hash) but different sizes. This is not actually a hash collision. In this case, we can deduplicate them and keep the one with the larger size. Change-Id: If6834542d7914cc00f917d7db151955e5aee6f30 Reviewed-on: https://go-review.googlesource.com/c/go/+/243718 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-16[dev.link] cmd/link: stream out external relocations on AMD64 ELFCherry Zhang
Currently, when external linking, in relocsym (in asmb pass), we convert Go relocations to an in-memory representation of external relocations, and then in asmb2 pass we write them out to the output file. This is not memory efficient. This CL makes it not do the conversion but directly stream out the external relocations based on Go relocations. Currently only do this on AMD64 ELF systems. This reduces memory usage, but makes the asmb2 pass a little slower. Linking cmd/compile with external linking: name old time/op new time/op delta Asmb_GC 83.8ms ± 7% 70.4ms ± 4% -16.03% (p=0.008 n=5+5) Asmb2_GC 95.6ms ± 4% 118.2ms ± 5% +23.65% (p=0.008 n=5+5) TotalTime_GC 1.59s ± 2% 1.62s ± 1% ~ (p=0.151 n=5+5) name old alloc/op new alloc/op delta Asmb_GC 26.0MB ± 0% 4.1MB ± 0% -84.15% (p=0.008 n=5+5) Asmb2_GC 8.19MB ± 0% 8.18MB ± 0% ~ (p=0.222 n=5+5) name old live-B new live-B delta Asmb_GC 49.2M ± 0% 27.4M ± 0% -44.38% (p=0.008 n=5+5) Asmb2_GC 51.5M ± 0% 29.7M ± 0% -42.33% (p=0.008 n=5+5) TODO: figure out what is slow. Possible improvements: - Remove redundant work in relocsym. - Maybe there is a better representation for external relocations now. - Fine-grained parallelism in emitting external relocations. - The old elfrelocsect only iterates over external relocations, now we iterate over all relocations. Is it too many? Change-Id: Ib0a8ee8c88d65864c62b89a8d634614f7f2c813e Reviewed-on: https://go-review.googlesource.com/c/go/+/242603 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-16[dev.link] cmd/internal/goobj2, cmd/link: use short hash function for short ↵Cherry Zhang
symbols For symbols of size 8 bytes or below, we can map them to 64-bit hash values using the identity function. There is no need to use longer and more expensive hash functions. For them, we introduce another pseudo-package, PkgIdxHashed64. It is like PkgIdxHashed except that the hash function is different. Note that the hash value is not affected with trailing zeros, e.g. "A" and "A\0\0\0" have the same hash value. This allows deduplicating a few more symbols. When deduplicating them, we need to keep the longer one. Change-Id: Iad0c2e9e569b6a59ca6a121fb8c8f0c018c6da03 Reviewed-on: https://go-review.googlesource.com/c/go/+/242362 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-16[dev.link] cmd/internal/obj: make integer/float constant symbols ↵Cherry Zhang
content-addressable Fill in the data at compile time, and get rid of the preprocess function in the linker. We need to be careful with symbol alignment: data symbols are generally naturally aligned, except for string symbols which are not aligned. When deduplicating two symbols with same content but different alignments, we need to keep the biggest alignment. Change-Id: I4bd96adfdc5f704b5bf3a0e723457c9bfe16a684 Reviewed-on: https://go-review.googlesource.com/c/go/+/242081 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-16[dev.link] cmd/internal/goobj2, cmd/link: add content addressable symbolsCherry Zhang
This CL introduces content-addressable symbols (a.k.a. hashed symbols) to object files. Content-addressable symbols are identified and referenced by their content hashes, instead of by names. In the object file, a new pseudo-package index PkgIdxHashed is introduced, for content-addressable symbols, and a new block is added to store their hashes. The hashes are used by the linker to identify and deduplicate the symbols. For now, we only support content-addressable symbols that are always locally defined (i.e. no cross-package references). As a proof of concept, make string constant symbols content- addressable. Change-Id: Iaf53efd74c0ffb54fa95f784628cc84e95844536 Reviewed-on: https://go-review.googlesource.com/c/go/+/242079 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-08[dev.link] cmd/link: skip symtab entries for selected file local symbolsThan McIntosh
Don't emit symbol table entries for compiler-generated file-local symbols (this category includes .stmp_* temporaries and *.stkobj symbols). Note that user-written static symbols within assembler sources will still be added to the symbol table. Apply the same test when emitting DWARF for global variables. Change-Id: I4db77a2750a0b575e051dfea895c4742cf6709a6 Reviewed-on: https://go-review.googlesource.com/c/go/+/240539 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-07-06[dev.link] cmd/link: better naming for Loader container/subsym methods, part ↵Than McIntosh
2 of 2 Introduce a new loader method "SetCarrierSym", to be used when establishing container/containee symbol relationships for symbol bucketing in the symtab phase. This new method is intended to be employed in situations where you have a series of related symbols will be represented by a single carrier symbol as a combined entity. The pattern here is that the sub-symbols contain content but will be anonymous from a symbol table perspective; the carrier symbol has no content itself but will appear in the symbol table. Examples of carrier symbols that follow this model are "runtime.itablink" and "runtime.typelink". Change-Id: I1a3391a71062c7c740cb108b3fa210b7f69b81ed Reviewed-on: https://go-review.googlesource.com/c/go/+/240509 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-06[dev.link] cmd/link: better naming for Loader container/subsym methods, part ↵Than McIntosh
1 of 2 Introduce a new loader method "AddInteriorSym" to be used when establishing container/containee symbol relationships for host object sub-symbols and GOT/dynamic sub-symbols. Interior symbols are employed in situations where you have a "container" or "payload" symbol that has content, and then a series of "interior" sub-symbols that point into a portion of the container symbol's content. Each interior symbol will typically have a useful name / size / value, but no content of its own. From a symbol table perspective the container symbol is anonymous, but the interior symbols are added to the output symbol table. Change-Id: I919ed5dbbfe2ef2c9a76214f7ea9b384a1be6297 Reviewed-on: https://go-review.googlesource.com/c/go/+/240508 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-06-25[dev.link] cmd/link: add generator symbolsJeremy Faller
Create a new class of symbols internal to the linker. These symbols live in the Loader, and are real smybols, but have no data, only size. After symbols are allocated in the binary in asmb() a function is called that is responsible for filling in the data. This allows the linker to create large symbols, but not pay the price on the heap memory. Change-Id: Ib4291fc6e578478057ed2ec163d7b27426f1d5ff Reviewed-on: https://go-review.googlesource.com/c/go/+/239280 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-06-25[dev.link] cmd/internal: convert basic types to builtin symbolsThan McIntosh
The Go compiler includes special treatment for a small set of very commonly used type symbols (26 to be exact); for these types it doesn't bother to emit type descriptors for "normal" compilations, and instead only generates them for the runtime package, so as to reduce object file bloat. This patch moves the set of type symbols in question from the PkgIdxNone index space (in the object file) to the PkgIdxBuiltin space, which saves some work in the compiler and loader (reduces each package's index space slightly). Change-Id: I039c805e05c1aef26f035e52760fd0a0af40f7a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/239658 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-06-17[dev.link] cmd/link: remove implicit reachability setting from SymbolBuilderThan McIntosh
The loader's SymbolBuilder Add*/Set* methods include a call to mark the underlying symbol as reachable (as a convenience, so that callers would not have to set it explicitly). This code was carried over from the corresponding sym.Symbol methods; back in the sym.Symbol world unreachable symbols were never removed from the AllSyms slice, hence setting and checking reachability was a good deal more important. With the advent of the loader and the new deadcode implementation, there is less of a need for this sort of fallback, and in addition the implicit attr setting introduces data races in the the loader if there are SymbolBuilder Add*/Set* method calls in parallel threads, as well as adding overhead to the methods. This patch gets rid of the implicit reachability setting, and instead marks reachability in CreateSymForUpdate, as well as adding a few explicit SetAttrReachable calls where needed. Change-Id: I029a0c5a4a24237826a7831f9cbe5180d44cbc40 Reviewed-on: https://go-review.googlesource.com/c/go/+/237678 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-06-11[dev.link] cmd/compile, cmd/link: remove dead methods if type is not used in ↵Cherry Zhang
interface Currently, a method of a reachable type is live if it matches a method of a reachable interface. In fact, we only need to retain the method if the type is actually converted to an interface. If the type is never converted to an interface, there is no way to call the method through an interface method call (but the type descriptor could still be used, e.g. in calling runtime.newobject). A type can be used in an interface in two ways: - directly converted to interface. (Any interface counts, as it is possible to convert one interface to another.) - obtained by reflection from a related type (e.g. obtaining an interface of T from []T). For the former, we let the compiler emit a marker on the type descriptor symbol when it is converted to an interface. In the linker, we only need to check methods of marked types. For the latter, when the linker visits a marked type, it needs to visit all its "child" types as marked (i.e. potentially could be converted to interface). This reduces binary size: cmd/compile 18792016 18706096 (-0.5%) cmd/go 14120572 13398948 (-5.1%) Change-Id: I4465c7eeabf575f4dc84017214c610fa05ae31fd Reviewed-on: https://go-review.googlesource.com/c/go/+/237298 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-06-11[dev.link] all: merge branch 'master' into dev.linkCherry Zhang
Change-Id: I446db56b20ef2189e23e225a91a17736c1d11e4c
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-05[dev.link] all: merge branch 'master' into dev.linkCherry Zhang
Merge conflicts are mostly recently changed nm/objdump output format and its tests. Resolved easily (mostly just using the format on master branch). Change-Id: I99d8410a9a02947ecf027d9cae5762861562baf5
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-26[dev.link] cmd/{compile,link}: split SDWARFINFO symtype into sub-typesThan McIntosh
This change splits the SDWARFINFO symbol type (a generic container of DWARF content) into separate sub-classes. The new symbol types are SDWARFCUINFO comp unit DIE, also CU info and CU packagename syms SDWARFCONST constant DIE SDWARFFCN subprogram DIE (default and concrete) SDWARFABSFCN abstract function DIE SDWARFTYPE type DIE SDWARFVAR global variable DIE Advantage of doing this: in the linker there are several places where we have to iterate over a symbol's relocations to pick out references to specific classes of DWARF sub-symbols (for example, looking for all abstract function DIEs referenced by a subprogram DIE, or looking at all the type DIEs used in a subprogram DIE). By splitting SDWARFINFO into parts clients can now look only at the relocation target's sym type as opposed to having to materialize the target sym name, or do a lookup. Change-Id: I4e0ee3216d3c8f1a78bec3d296c01e95b3d025b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/234684 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-21[dev.link] cmd/link: delete sym.SymbolsCherry Zhang
Now the only thing it does is to track versions. Move it to ctxt. And delete sym.Symbols. Change-Id: Ie6b974f9bf79c4f33ace02213dcb89463eadd26a Reviewed-on: https://go-review.googlesource.com/c/go/+/234884 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-21[dev.link] all: merge branch 'master' into dev.linkCherry Zhang
Change-Id: I85b653b621ad8cb2ef27886210ea2c4b7409b60d
2020-05-19[dev.link] cmd/link: remove duplicate handling of some specially named symbolsCherry Zhang
We do it on the symtab pass. Remove duplicate. Change-Id: I88cc8cd6e873749e0f6197f809aa812bca9dbbf9 Reviewed-on: https://go-review.googlesource.com/c/go/+/234493 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-19[dev.link] cmd/link: only do name expansion when neededCherry Zhang
Most Go objects are compiled with known package path, so the symbol name is already fully expanded. Nevertheless, currently in the linker strings.Replace is called unconditionally, and most of the time it doesn't do anything. This CL records a per-object flag in the object file, and do the name expansion only when the name is not expanded at compile time. This gives small speedups for the linker. Linking cmd/compile: name old time/op new time/op delta Loadlib 35.1ms ± 2% 32.8ms ± 4% -6.43% (p=0.008 n=5+5) Symtab 15.8ms ± 2% 14.0ms ± 8% -11.45% (p=0.008 n=5+5) TotalTime 399ms ± 1% 385ms ± 2% -3.63% (p=0.008 n=5+5) Change-Id: I735084971a051cd9be4284ad294c284cd5b545f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/234490 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-18[dev.link] cmd/link: remove "2" from namesCherry Zhang
Change-Id: I203caaf9cbe7136cf2060de7dc91c28f6ced1ee2 Reviewed-on: https://go-review.googlesource.com/c/go/+/234038 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-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-14[dev.link] cmd/link: delete sym.Symbol and sym.RelocCherry Zhang
This deletes all sym.Symbol and sym.Reloc references. This is certainly not complete, and there are more cleanups to do. But I feel this makes a good first round. Change-Id: I7621d016957f7ef114be5f0606fcb3ad6aee71c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/234097 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-14[dev.link] cmd/internal/goobj2, cmd/link: change data type for local ↵Cherry Zhang
object/index representation Use uint32 consistently for local index (this is what the object file uses). Use a index, instead of a pointer, to refer to the object file. This reduces memory usage and GC work. This reduces some allocations. Linking cmd/compile, name old alloc/op new alloc/op delta Loadlib_GC 19.9MB ± 0% 16.9MB ± 0% -15.33% (p=0.008 n=5+5) name old live-B new live-B delta Loadlib_GC 12.6M ± 0% 11.3M ± 0% -9.97% (p=0.008 n=5+5) Change-Id: I20ce60bbb6d31abd2e9e932bdf959e2ae840ab98 Reviewed-on: https://go-review.googlesource.com/c/go/+/233779 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-13[dev.link] cmd/link/internal/loader: remove Propagate* shim functionsThan McIntosh
Remove the loader's PropagateSymbolChangesBackToLoader and PropagateLoaderChangesToSymbols shim functions. These were used at one point to enable conversion of phases in the linker that were "downstream" of loadlibfull -- given the current wavefront position there's not much point keeping them around. Change-Id: I3f01f25b70b1b80240369c8f3a10dca89931610f Reviewed-on: https://go-review.googlesource.com/c/go/+/233817 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-05-13[dev.link] cmd/link: remove extSymPayload.gotype fieldCherry Zhang
We have the information from auxs. Remove the field, slightly reduce memory usage. Change-Id: I3881777cfb40b03d0e2b0e7a326b0738080548b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/233778 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-12[dev.link] cmd/link: remove elfsetstringCherry Zhang
No longer needed. Change-Id: I7cd08915e4731c4546414340df69521e2347367f Reviewed-on: https://go-review.googlesource.com/c/go/+/233521 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-12[dev.link] cmd/link: reduce allocations in PreloadCherry Zhang
Don't create loader.Syms until LoadFull (it will be gone soon anyway.) Preallocate loader.objSym array. Don't create loader.values until preloading is done. Linking cmd/compile: name old alloc/op new alloc/op delta Loadlib_GC 36.2MB ± 0% 20.0MB ± 0% -44.91% (p=0.016 n=5+4) Change-Id: I82eddcfa7fb8fc4e84e8174a47e59cf1183dd83b Reviewed-on: https://go-review.googlesource.com/c/go/+/233341 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>