aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/deadcode.go
AgeCommit message (Collapse)Author
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-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-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-04[dev.link] cmd/link: reuse slice memory in deadcode passCherry Zhang
Reuse slice memory in the deadcode pass, reduce allocations. Linking cmd/compile, name old alloc/op new alloc/op delta Deadcode_GC 2.10MB ± 0% 1.41MB ± 0% -32.61% (p=0.008 n=5+5) name old allocs/op new allocs/op delta Deadcode_GC 8.46k ± 0% 5.55k ± 0% -34.45% (p=0.008 n=5+5) Change-Id: Ib9ba0928d68a65879007218697712b53acd3c5c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/236566 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-06-04[dev.link] cmd/link: rewrite heap algorithmCherry Zhang
Instead of using container/heap package, implement a simple specialized heap algorithm for the work queue in the deadcode pass, to avoid allocations and function pointer calls. Linking cmd/compile, name old time/op new time/op delta Deadcode_GC 59.8ms ± 4% 42.2ms ± 4% -29.45% (p=0.008 n=5+5) name old alloc/op new alloc/op delta Deadcode_GC 3.53MB ± 0% 2.10MB ± 0% -40.57% (p=0.008 n=5+5) name old allocs/op new allocs/op delta Deadcode_GC 187k ± 0% 8k ± 0% -95.48% (p=0.008 n=5+5) Change-Id: Ibb21801d5b8e4a7eaf429856702e02720cd1772f Reviewed-on: https://go-review.googlesource.com/c/go/+/236565 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-06-04[dev.link] cmd/link: compare type descriptors for interface satisfaction ↵Cherry Zhang
analysis Currently, in the deadcode pass, when checking whether a defined method satisfies an interface, it compares the string representation of the defined method and the interface method. In fact, it can simply compare the method name and the type descriptor (as we do in runtime). Make it so. Change-Id: Ideb2b2410e5eedcd20ac31e3af41f5499fc90225 Reviewed-on: https://go-review.googlesource.com/c/go/+/236564 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-01cmd/link: expand a TODO commentCherry Zhang
CL 231397 is submitted too fast... Expand the comment to make it a little clearer. Change-Id: Ica9737aa7b51f97320bab74457388dcab8188370 Reviewed-on: https://go-review.googlesource.com/c/go/+/231597 Reviewed-by: Austin Clements <austin@google.com>
2020-05-01cmd/link: don't mark a symbol's Gotype reachableCherry Zhang
A symbol being reachable doesn't imply its type descriptor is needed. Don't mark it. If the type is converted to interface somewhere in the program, there will be an explicit use of the type descriptor, which will make it marked. A println("hello") program before and after -rwxr-xr-x 1 cherryyz primarygroup 1259824 Apr 30 23:00 hello -rwxr-xr-x 1 cherryyz primarygroup 1169680 Apr 30 23:10 hello Updates #38782. Updates #6853. Change-Id: I88884c126ce75ba073f1ba059c4b892c87d2ac96 Reviewed-on: https://go-review.googlesource.com/c/go/+/231397 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-30[dev.link] cmd/link: combine decodesym.go and decodesym2.goCherry Zhang
And remove "2" from some function names. Change-Id: Ibf1089970d849a42f53976064ceb9ade20bf6eba Reviewed-on: https://go-review.googlesource.com/c/go/+/231017 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: 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-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-19cmd/link: check for reflect.Value.MethodByName explicitlyCherry Zhang
Currently we only check for reflect.Value.Method. And reflect.Value.MethodByName is covered since it calls reflect.Value.Method internally. But it is brittle to rely on implementation detail of the reflect package. Check for MethodByName explicitly. Change-Id: Ifa8920e997524003dade03abc4fb3c4e64723643 Reviewed-on: https://go-review.googlesource.com/c/go/+/228881 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-18cmd/link: update comment for deadcodeCherry Zhang
Update the comment to be in sync with the code. Change-Id: I19586767a37347c4da1b4d3f7c6dc6cc2292a90f Reviewed-on: https://go-review.googlesource.com/c/go/+/228877 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
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-03-05[dev.link] cmd/link: fix up ctxt.Textp2 handling in AssignTextSymbolOrderThan McIntosh
Change the loader method AssignTextSymbolOrder to return a slice of all reachable textp symbols, since it will be needed in second-phase DWARF gen. Change-Id: Iaf16ee9cf0d5266aeb0d3df596e8117263b35d8e Reviewed-on: https://go-review.googlesource.com/c/go/+/220985 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-02-19[dev.link] cmd/link: convert DWARF type generation to use loaderThan McIntosh
Converts the portion of DWARF generation that deals with creation of type DIEs and constant DIEs to use the new loader interfaces. Creation of subprogram DIE and compilation unit DIE content still operates on sym.Symbols at the moment, and happens much later in the linker. The new code for type DIE generation is gated/guarded by the linker flag "-newdw", which currently defaults to true. At some point in the near future this flag should be removed, but it is handy for triage at the moment. This patch also includes shim code designed to run after loadlibfull() that walks through the DIE chains and to converts loader.Sym references back into sym.Symbol references for the remainder of the compilation, since the second phase of DWARF has not yet been converted. Change-Id: I681a00fb8a1f3c37884a79b373d86411332e07c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/208230 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-01-06[dev.link] cmd/link: keep loader symbol info in sym.CompilationUnitThan McIntosh
In sym.Library and sym.CompilationUnit there are slices of *sym.Symbol pointer that hold text symbols contained in the unit lib. To support DWARF generation with new loader, add equivalent slices that hold loader.Sym values for functions in scope. This will be needed if at some point we push the sym.Symbol creation "wavefront" beyond dwarf gen. This patch also insures that live host object symbols are added to the context Textp2 slice, since they would not make it on otherwise. [NB: not sure if this is the best way to do this.] Change-Id: I4f440e12cebc525b1e37082ad39cf7338aeb6b99 Reviewed-on: https://go-review.googlesource.com/c/go/+/208231 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-11-12[dev.link] cmd/link: delete old object file format supportCherry Zhang
There are more cleanups to do, but I want to keep this CL mostly a pure deletion. Change-Id: I30f4891a2ea54545fd6b83041746ab65895537e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/206558 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-11-01[dev.link] all: merge branch 'master' into dev.linkThan McIntosh
Fixed a couple of minor conflicts in lib.go and deadcode.go relating to debug logging. Change-Id: I58335fc42ab1f1f3409fd8354da4f26419e8fb22
2019-10-26cmd/link/internal: eliminate all ld.Cputime() usagesnikita-vanyasin
Also a similar 'elapsed' function and its usages were deleted. Fixes #19865. Change-Id: Ib125365e69cf2eda60de64fa74290c8c7d1fd65a Reviewed-on: https://go-review.googlesource.com/c/go/+/171730 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-15[dev.link] cmd/link: create sym.Symbols after deadcode in newobj modeCherry Zhang
With the new object files, now we can run the deadcode pass on indices instead of Symbol structs, so we can delay creating Symbols after the deadcode pass. Then we only need to create reachable symbols. Not create Symbols in LoadNew and LoadRefs, and recombine LoadReloc into LoadFull. Split loadcgo into two parts: the first finds root symbols, the second create Symbols and sets attributes. The first runs before the deadcode pass, while the second runs after. TODO: currently there are still symbols that are not marked reachable but still used. This includes DWARF symbols, file symbols, and type symbols that are referenced by DWARF symbols. We still need to create them (conservatively). Change-Id: I695779c9312be9d49ab1683957ac3e72e1f65a1e Reviewed-on: https://go-review.googlesource.com/c/go/+/199643 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-10[dev.link] cmd/link: use index for deadcodeCherry Zhang
Switch the deadcode pass to use indices instead of Symbol structures when using new object file format. Delay loading symbol relocations and contents fully after the deadcode pass. The next step is not to create Symbol structures until deadcode is done. Method tracking logic hasn't been implemented. Currently, all methods of a reachable type are live. Change-Id: Iffcd06ff84e6e52bd9eb24d1220d94234d18ab6b Reviewed-on: https://go-review.googlesource.com/c/go/+/198199 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-09[dev.link] cmd/link: change some decodetype functions to operate on bytesCherry Zhang
Change some decodetype functions to operate on bytes nstead of Symbol. This is in preparation of implementing live method tracking in index-based deadcode pass, and reducing/eliminating sym.Symbol in general. Change-Id: Ia9809ad7b182884225e1bda577e8dbec0cd216c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/199077 Reviewed-by: Austin Clements <austin@google.com>
2019-10-09[dev.link] cmd/link: load full symbol contents after deadcode passCherry Zhang
If the new object file format is used, now we load full symbol contents after the deadcode pass, for reachable symbols only. We still load some informations early, like relocations and the contents of type symbols, which are used in the deadcode pass. If we rewrite deadcode to use index directly, we could delay more of the loading (to sym.Symbol), and perhaps delay the creation of sym.Symbol. TODO: internal linking with host objects doesn't work yet. Change-Id: I7d4880e8f150e8709ffac277e62191623440e4cf Reviewed-on: https://go-review.googlesource.com/c/go/+/197258 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-08[dev.link] cmd/link: add symbols to Textp after deadcode passCherry Zhang
Currently we add all text symbols to ctxt.Textp at load time, then the deadcode pass filters out unreachable ones. This CL delays adding symbols to ctxt.Textp to the end of the deadcode pass, where we only add reachable ones. Change-Id: Ie83b2958f915c5aaa004b8c5ed1f1bc275f4d1db Reviewed-on: https://go-review.googlesource.com/c/go/+/197257 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2019-09-27cmd/link: remove reading/processing of function Autom recordsThan McIntosh
Remove linker reading and processing of automs (no longer needed, now that the compiler is emitting R_USETYPE relocations on functions). So as to avoid changing the object file format, the object still contains a count of automs, but this count is required to be zero. Updates #34554. Change-Id: I10230e191057c5c5705541eeb06f747d5f73c42d Reviewed-on: https://go-review.googlesource.com/c/go/+/197500 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-09-24cmd/link: add notion of multiple compilation units per packageJeremy Faller
As we move the debug_line generation into the compiler, we need to upgrade the notion of compilationUnit to not just be on a per package basis. That won't be the case as it will be impossible for all compilationUnits to have the same set of files names used to build the debug_lines table. (For example, assembled files in a package don't know about any files but themselves, so the debug_lines table could only reference themseves. As such, we need to break the 1:1 relationship between compUnit and package.) Change-Id: I2e517bb6c01de0115bbf777af828a2fe59c09ce8 Reviewed-on: https://go-review.googlesource.com/c/go/+/189618 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-18cmd/compile: reorganize init functionsKeith Randall
Instead of writing an init function per package that does the same thing for every package, just write that implementation once in the runtime. Change the compiler to generate a data structure that encodes the required initialization operations. Reduces cmd/go binary size by 0.3%+. Most of the init code is gone, including all the corresponding stack map info. The .inittask structures that replace them are quite a bit smaller. Most usefully to me, there is no longer an init function in every -S output. (There is an .inittask global there, but it's much less distracting.) After this CL we could change the name of the "init.ializers" function back to just "init". Update #6853 R=go1.13 Change-Id: Iec82b205cc52fe3ade4d36406933c97dbc9c01b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/161337 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-02-26cmd/link: delete stale deadcode referenceAustin Clements
Back when the linker did code generation after dead code elimination, it had to know that references to runtime.read_tls_fallback could be generated at code generation time (and never appear before that). Now that code generation is done by the compiler, the references to runtime.read_tls_fallback are obvious in the relocations, so the linker no longer needs special knowledge of this symbol. Change-Id: I9813a8478e85a6a13470b2d0528db53fd33fcfdf Reviewed-on: https://go-review.googlesource.com/c/154601 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-12cmd/compile, cmd/link: separate stable and internal ABIsAustin Clements
This implements compiler and linker support for separating the function calling ABI into two ABIs: a stable and an internal ABI. At the moment, the two ABIs are identical, but we'll be able to evolve the internal ABI without breaking existing assembly code that depends on the stable ABI for calling to and from Go. The Go compiler generates internal ABI symbols for all Go functions. It uses the symabis information produced by the assembler to create ABI wrappers whenever it encounters a body-less Go function that's defined in assembly or a Go function that's referenced from assembly. Since the two ABIs are currently identical, for the moment this is implemented using "ABI alias" symbols, which are just forwarding references to the native ABI symbol for a function. This way there's no actual code involved in the ABI wrapper, which is good because we're not deriving any benefit from it right now. Once the ABIs diverge, we can eliminate ABI aliases. The linker represents these different ABIs internally as different versions of the same symbol. This way, the linker keeps us honest, since every symbol definition and reference also specifies its version. The linker is responsible for resolving ABI aliases. Fixes #27539. Change-Id: I197c52ec9f8fc435db8f7a4259029b20f6d65e95 Reviewed-on: https://go-review.googlesource.com/c/147160 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2018-08-21cmd/link/internal/ld: avoid Reloc copies in range loopsisharipo
Copying sym.Reloc in loops hurts performance as it has 48 byte size (on 64-bit platforms). There are quite many symbols and each of them has more than 1 relocation (so, it's possible to have more than 1kk relocs). The're also traversed more than once in some code paths. By using pointers to them, copies are avoided. For linking "hello world" example from net/http: name old time/op new time/op delta Linker-4 530ms ± 2% 521ms ± 3% -1.80% (p=0.000 n=17+20) Change-Id: I6518aec69d6adcd137f84b5c089ceab4cb4ea2dd Reviewed-on: https://go-review.googlesource.com/113636 Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-03cmd/link: use side table instead of sym.Symbol 'Reachparent' fieldThan McIntosh
The sym.Symbol 'Reachparent' field is used only when field tracking is enabled. So as to use less memory for the common case where field tracking is not enabled, remove this field and use a side table stored in the context to achieve the same functionality. Updates #26186 Change-Id: Idc5f8b0aa323689d4d51dddb5d1b0341a37bb7d2 Reviewed-on: https://go-review.googlesource.com/121915 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-04-27cmd/link/internal/ld: simple cleanupsDaniel Martí
Simplify some C-style loops with range statements, and move some declarations closer to their uses. While at it, ensure that all the SymbolType consts are typed. Change-Id: I04b06afb2c1fb249ef8093a0c5cca0a597d1e05c Reviewed-on: https://go-review.googlesource.com/105217 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-01compile, link: remove base address selector from DWARF range listsAlessandro Arzilli
Dsymutil, an utility used on macOS when externally linking executables, does not support base address selector entries in debug_ranges. To work around this deficiency this commit removes base address selectors from debug_ranges and emits instead a list composed only of compile unit relative addresses. A new type of relocation is introduced, R_ADDRCUOFF, similar to R_ADDROFF, that relocates an address to its offset from the low_pc of the symbol's compile unit. Fixes #21945 Change-Id: Ie991f9bc1afda2b49ac5d734eb41c37d3a37e554 Reviewed-on: https://go-review.googlesource.com/72371 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
2017-10-26cmd/link, plugin: always encode pathDavid Crawshaw
Both the linker and the plugin package were inconsistent about when they applied the path encoding defined in objabi.PathToPrefix. As a result, only some symbols from a package path that required encoding were being found. So always encoding the path. Fixes #22295 Change-Id: Ife86c79ca20b2e9307008ed83885e193d32b7dc4 Reviewed-on: https://go-review.googlesource.com/72390 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-21cmd/link: move Headtype global to ctxtDavid Crawshaw
For #22095 Change-Id: Idcfdfe8a94db8626392658bb93429454238f648a Reviewed-on: https://go-review.googlesource.com/70835 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-20cmd/link: move FlagLinkshared global to ctxtDavid Crawshaw
For #22095 Change-Id: Ica6b3391541fe5a0355620d7c4a5107cf53eee82 Reviewed-on: https://go-review.googlesource.com/70833 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-06cmd/link: move build/link mode globals into ctxtDavid Crawshaw
Replace Buildmode with BuildMode and Linkmode with LinkMode. For #22095 Change-Id: I51a6f5719d107727bca29ec8e68e3e9d87e31e33 Reviewed-on: https://go-review.googlesource.com/68334 Run-TryBot: David Crawshaw <crawshaw@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-05all: revert "all: prefer strings.IndexByte over strings.Index"Marvin Stenger
This reverts https://golang.org/cl/65930. Fixes #22148 Change-Id: Ie0712621ed89c43bef94417fc32de9af77607760 Reviewed-on: https://go-review.googlesource.com/68430 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05cmd/link: put symbol data types in new packageDavid Crawshaw
For #22095 Change-Id: I07c288208d94dabae164c2ca0a067402a8e5c2e6 Reviewed-on: https://go-review.googlesource.com/68331 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-03cmd/link: remove SysArch global variableDavid Crawshaw
For #22095 Change-Id: I9d1f0d93f8fd701a24af826dc903eea2bc235de2 Reviewed-on: https://go-review.googlesource.com/67317 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-25all: prefer strings.IndexByte over strings.IndexMarvin Stenger
strings.IndexByte was introduced in go1.2 and it can be used effectively wherever the second argument to strings.Index is exactly one byte long. This avoids generating unnecessary string symbols and saves a few calls to strings.Index. Change-Id: I1ab5edb7c4ee9058084cfa57cbcc267c2597e793 Reviewed-on: https://go-review.googlesource.com/65930 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-14cmd/link: don't emit default entry symbol in some situationsHiroshi Ioka
Also, fix comment. Change-Id: Ieb7ba21f34730dc51ab45a652d225e4145d4b861 Reviewed-on: https://go-review.googlesource.com/54870 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-27cmd/internal/objabi, cmd/link: move linker-only symkind values into linkerMichael Hudson-Doyle
Many (most!) of the values of objapi.SymKind are used only in the linker, so this creates a separate cmd/link/internal/ld.SymKind type, removes most values from SymKind and maps one to the other when reading object files in the linker. Two of the remaining objapi.SymKind values are only checked for, never set and so will never be actually found but I wanted to keep this to the most mechanical change possible. Change-Id: I4bbc5aed6713cab3e8de732e6e288eb77be0474c Reviewed-on: https://go-review.googlesource.com/40985 Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-19cmd/internal/objabi: extract shared functionality from objMatthew Dempsky
Now only cmd/asm and cmd/compile depend on cmd/internal/obj. Changing the assembler backends no longer requires reinstalling cmd/link or cmd/addr2line. There's also now one canonical definition of the object file format in cmd/internal/objabi/doc.go, with a warning to update all three implementations. objabi is still something of a grab bag of unrelated code (e.g., flag and environment variable handling probably belong in a separate "tool" package), but this is still progress. Fixes #15165. Fixes #20026. Change-Id: Ic4b92fac7d0d35438e0d20c9579aad4085c5534c Reviewed-on: https://go-review.googlesource.com/40972 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-03-12cmd/link: eliminate markextraMatthew Dempsky
This appears to be leftover from when instruction selection happened in the linker. Many of the morestackX functions listed don't even exist anymore. Now that we select instructions within the compiler and assembler, normal deadcode elimination mechanisms should suffice for these symbols. Change-Id: I2cb1e435101392e7c983957c4acfbbcc87a5ca7d Reviewed-on: https://go-review.googlesource.com/38077 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-07cmd/link, crypto/tls: don't use append loopsDaniel Martí
Change-Id: Ib47e295e8646b769c30fd81e5c7f20f964df163e Reviewed-on: https://go-review.googlesource.com/36335 Reviewed-by: Filippo Valsorda <hi@filippo.io> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-22cmd/compile, cmd/link: weak relocation for ptrToDavid Crawshaw
Introduce R_WEAKADDROFF, a "weak" variation of the R_ADDROFF relocation that will only reference the type described if it is in some other way reachable. Use this for the ptrToThis field in reflect type information where it is safe to do so (that is, types that don't need to be included for interface satisfaction, and types that won't cause the compiler to recursively generate an endless series of ptr-to-ptr-to-ptr-to... types). Also fix a small bug in reflect, where StructOf was not clearing the ptrToThis field of new types. Fixes #17931 Change-Id: I4d3b53cb9c916c97b3b16e367794eee142247281 Reviewed-on: https://go-review.googlesource.com/33427 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-11cmd/link: use plugin path in visibility analysisDavid Crawshaw
CL 32355 switched from using the output file as a plugin prefix to the full package path. The linker dead code analysis was not updated. Updates #17821 Change-Id: I13fc45e0264b425d28524ec54c829e2c3e895b0b Reviewed-on: https://go-review.googlesource.com/32916 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03cmd/compile: write type symbols referenced in ptabsDavid Crawshaw
The exported symbol for a plugin can be the only reference to a type in a program. In particular, "var F func()" will have the type *func(), which is uncommon. Fixes #17140 Change-Id: Ide2104edbf087565f5377374057ae54e0c00c57e Reviewed-on: https://go-review.googlesource.com/29692 Run-TryBot: David Crawshaw <crawshaw@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>