aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/loader/loader.go
AgeCommit message (Collapse)Author
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>
2020-04-07[dev.link] cmd/link/internal/loader: speed up Loader.RelocVariantThan McIntosh
Remove some extra sanity-checking code from the loader's RelocVariant method, since it was yielding a slowdown of 1-2% linking kubernetes hyperkube (once again a reminder that relocation processing is a very performance-sensitive part of the linker). Change-Id: Ifbc0662f3f96c5f54131103ce6f7439ecfb9b9dc Reviewed-on: https://go-review.googlesource.com/c/go/+/227477 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-06[dev.link] cmd/link/internal/loader: support 'variant' relocationsThan McIntosh
Add support to the loader for getting/setting the 'variant' property of a symbol relocation. The variant property handles unusual or infrequently used relocations that have both a type and a variant of that type (this is needed for S390). In the sym.Symbol world, a relocation variant is a field on the 'relocExt' extension that is part of sym.Reloc. In this new implementation for the loader, reloc variants are stored in a side table (a map) in the loader, and accessed via loader methods. Change-Id: I62bf54ae7ff6d500c0ea8d2dbe759b2431087378 Reviewed-on: https://go-review.googlesource.com/c/go/+/227018 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-02[dev.link] cmd: support large function alignmentCherry Zhang
This ports CL 226997 to the dev.link branch. - The assembler part and old object file writing are unchanged. - Changes to cmd/link are applied to cmd/oldlink. - Add alignment field to new object files for the new linker. Change-Id: Id00f323ae5bdd86b2709a702ee28bcaa9ba962f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/227025 Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-01[dev.link] cmd/internal/goobj2, cmd/link: add and use new Sym accessorsCherry Zhang
Along the line with Reloc and Aux, use new-style accessors for the Sym type. They avoid reading unnecessary fields, and also look nicer (to me). Change-Id: Ie37c5149a6edb2184724b3dfa26952015e74c085 Reviewed-on: https://go-review.googlesource.com/c/go/+/226798 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-31[dev.link] cmd/link: unify Relocs.Count and len(rs)Cherry Zhang
The Count field in Relocs type is always equal to len(rs). Unify them. Change-Id: Ic77288ea58b61a98482b218e051d81047d0ddd88 Reviewed-on: https://go-review.googlesource.com/c/go/+/226717 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-31[dev.link] cmd/link: store external relocations in Reloc2 formatCherry Zhang
Store external relocations in (almost) the same format as the Go objects, so we can handle them more uniformly. There is a small speedup: (linking cmd/compile) Deadcode 67.8ms ± 3% 61.1ms ± 3% -9.94% (p=0.008 n=5+5) Dostkcheck 41.2ms ± 2% 38.8ms ± 3% -5.99% (p=0.008 n=5+5) Change-Id: I8616e10b26235904201d6c9465f5ae32a49c9949 Reviewed-on: https://go-review.googlesource.com/c/go/+/226365 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-30[dev.link] cmd/link/internal/loader: copy Dynid when migrating sym attrsThan McIntosh
Add support for migrating over the symbol Dynid property when converting loader.Sym symbols to sym.Symbol. Change-Id: Icc3b91b4adcae6f2ede7d915bb674cc206025217 Reviewed-on: https://go-review.googlesource.com/c/go/+/226360 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-30[dev.link] cmd/link: use new-style Aux accessors in the loaderCherry Zhang
And remove the old-style one. Change-Id: Ia6c84448108dd1da68451df2221c7c1005c45a0d Reviewed-on: https://go-review.googlesource.com/c/go/+/226364 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-03-30[dev.link] cmd/link: use new-style relocation accessors in LoadFullCherry Zhang
This gives some small speedup: (linking cmd/compile) Loadlibfull 77.8ms ± 6% 68.6ms ± 5% -11.88% (p=0.008 n=5+5) Also convert some Relocs.At to At2, which should have been done earlier. Change-Id: I2a66aeb5857234c6e645e1b23380149cffc8221f Reviewed-on: https://go-review.googlesource.com/c/go/+/226363 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-03-30[dev.link] cmd/link, cmd/oldlink: detect object file format mismatchCherry Zhang
When using the new(old) linker but an old(new) object file is found, give a better error message. Change-Id: I94786f1a4b527c15c4f5b00457eab60d215a72a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/225457 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-28[dev.link] cmd/link/internal/loader: add Loader plt/got access methodsThan McIntosh
Add accessor methods to get at the symbol {plt,got} value for PE symbols. Fix a bug in the loaders SetPlt/SetGot methods. Change-Id: I975bd6b86122622b206487c8798f8290ecd25a57 Reviewed-on: https://go-review.googlesource.com/c/go/+/225199 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-27[dev.link] cmd/link: migrate symbol's Value and Align when converting to ↵Cherry Zhang
sym.Symbols Currently, in LoadFull we migrate a symbol's Value to sym.Symbol only for external symbols. And symbol's Align is not migrated at all. As we move LoadFull forward, there are already places where we set symbol's Value and Align (e.g. in doelf). Migrate them correctly. Currently I think we only set them on external symbols, but as we move forward I think we'll need to set them on Go symbols as well. Change-Id: I63e97e38fc08b653ba9faefe15697944faf21bed Reviewed-on: https://go-review.googlesource.com/c/go/+/225658 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-03-25[dev.link] cmd/link: convert doxcoff to new styleCherry Zhang
Change-Id: Ic1e4ed6c14e049b1ba2f7c00f986433ab7ebe932 Reviewed-on: https://go-review.googlesource.com/c/go/+/225202 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>