aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/loader/loader_test.go
AgeCommit message (Collapse)Author
2025-12-09cmd: fix some issues in the commentscuishuang
Change-Id: Id2c4152b43c7ee1a687e49da7dda5a690e554231 Reviewed-on: https://go-review.googlesource.com/c/go/+/727900 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org>
2024-09-04all: fix printf(var) mistakes detected by latest printf checkerAlan Donovan
These will cause build failures once we vendor x/tools. In once case I renamed a function err to errf to indicate that it is printf-like. Updates golang/go#68796 Change-Id: I04d57b34ee5362f530554b7e8b817f70a9088d12 Reviewed-on: https://go-review.googlesource.com/c/go/+/610739 Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Tim King <taking@google.com> Auto-Submit: Alan Donovan <adonovan@google.com>
2024-03-07cmd/link: replace bytes.Compare call with bytes.Equalguoguangwu
Change-Id: Icc254cad3c861fd2b33228aa4d19424ce57a1b55 GitHub-Last-Rev: f557a696e4a5c632c49c7cd20745eeb771708f81 GitHub-Pull-Request: golang/go#66153 Reviewed-on: https://go-review.googlesource.com/c/go/+/569695 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-05-05cmd/link: remove elfsetstring out of the loaderCherry Mui
Currently, we pass elfsetstring to the loader as a callback, for a special case of Addstring. This is only used for ELF when adding strings to the section header string table. Move the logic to the caller instead, so the loader would not have this special case. Change-Id: Icfb91f380fe4ba435985c3019681597932f58242 Reviewed-on: https://go-review.googlesource.com/c/go/+/492718 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2023-03-29cmd/link,cmd/internal/objabi: support ADDR32NB relocations on windowsqmuntal
This CL updates the linker to support IMAGE_REL_[I386|AMD64|ARM|ARM64]_ADDR32NB relocations via the new R_PEIMAGEOFF relocation type. This relocation type references symbols using RVAs instead of VA, so it can use 4-byte offsets to reference symbols that would normally require 8-byte offsets. This new relocation is still not used, but will be useful when generating Structured Exception Handling (SEH) metadata, which needs to reference functions only using 4-byte addresses, thus using RVAs instead of VA is of great help. Updates #57302 Change-Id: I28d73e97d5cb78a3bc7194dc7d2fcb4a03f9f4d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/461737 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Davis Goodin <dagood@microsoft.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-09all: use ":" for compiler generated symbolsCuong Manh Le
As it can't appear in user package paths. There is a hack for handling "go:buildid" and "type:*" on windows/386. Previously, windows/386 requires underscore prefix on external symbols, but that's only applied for SHOSTOBJ/SUNDEFEXT or cgo export symbols. "go.buildid" is STEXT, "type.*" is STYPE, thus they are not prefixed with underscore. In external linking mode, the external linker can't resolve them as external symbols. But we are lucky that they have "." in their name, so the external linker see them as Forwarder RVA exports. See: - https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-address-table - https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/pe-dll.c;h=e7b82ba6ffadf74dc1b9ee71dc13d48336941e51;hb=HEAD#l972) This CL changes "." to ":" in symbols name, so theses symbols can not be found by external linker anymore. So a hacky way is adding the underscore prefix for these 2 symbols. I don't have enough knowledge to verify whether adding the underscore for all STEXT/STYPE symbols are fine, even if it could be, that would be done in future CL. Fixes #37762 Change-Id: I92eaaf24c0820926a36e0530fdb07b07af1fcc35 Reviewed-on: https://go-review.googlesource.com/c/go/+/317917 Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-12cmd/link: remove name expansion logicCherry Mui
Now both the compiler and the assembler require the -p flag and emit full package path in symbol names, we no longer need to do the name expansion in the linker. Delete it. Change-Id: I771d4d97987a0a17414881b52806d600ef4cc351 Reviewed-on: https://go-review.googlesource.com/c/go/+/404300 Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com>
2021-03-05cmd/internal/goobj: store relocation type as uint16Cherry Zhang
Currently, relocation type is stored as uint8 in object files, as Go relocations do not exceed 255. In the linker, however, it is used as a 16-bit type, because external relocations can exceed 255. The linker has to store the extra byte in a side table. This complicates many things. Just store it as uint16 in object files. This simplifies things, with a small cost of increasing the object file sizes. before after hello.o 1672 1678 runtime.a 7927784 8056194 Change-Id: I313cf44ad0b8b3b76e35055ae55d911ff35e3158 Reviewed-on: https://go-review.googlesource.com/c/go/+/268477 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
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-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-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-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-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-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-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-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-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-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-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-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>
2020-03-18[dev.link] cmd/link: remove AddExtSymCherry Zhang
They used to be different at some point, but now AddExtSym and LookupOrCreateSym are identical. Remove one. Change-Id: I299444d987e32a7f43915b3c1bbcc5ae906e9b6a Reviewed-on: https://go-review.googlesource.com/c/go/+/223977 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-02-13[dev.link] cmd/link: remove the second result of MakeSymbolUpdaterCherry Zhang
With unique global indices, MakeSymbolUpdater will not change the symbol's index. So no need to return a new index. Change-Id: I5b4fd6a0167cc74476880bbf4382c524ecde7721 Reviewed-on: https://go-review.googlesource.com/c/go/+/219227 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-02-12[dev.link] cmd/link: add defined package symbols first, before any ↵Cherry Zhang
non-package symbols Currently, the loader adds defined package symbols and non-package symbols to the global index space object by object. This CL changes it to add all the defined package symbols first, then all the non-package symbols. The advantage of doing this is that when adding package symbols, by definition they cannot be dup to each other, so we don't need to do a name lookup when adding them. We still add them to the lookup table (for now), since they may still be referenced by name (e.g. through linkname). This CL is also a prerequisite if we want to move to not adding package symbols to the lookup table entirely (e.g. by using pre-generated in-file lookup table). Also update some comments to reflect the current state. Change-Id: Ib757e070b48a9ef6215e47dc3421fc5c055b746c Reviewed-on: https://go-review.googlesource.com/c/go/+/219078 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-02-07[dev.link] cmd/link: clean up some fieldsCherry Zhang
With the new index mapping , we can clean up some fields. Loader.max should always be equal to len(loader.objSyms) now. And for external symbols we now give its "local index" as its index in the payload array, so Relocs.extIdx is no longer useful. Delete those fields. Change-Id: If387ff9201ea0d347b954f651f5d4b4ae74937aa Reviewed-on: https://go-review.googlesource.com/c/go/+/218478 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-02-05[dev.link] cmd/link: remove holes from global index spaceCherry Zhang
In CL 217064, we made symbol's global index unique, but we still reserve index space for each object file, which means we may leave holes in the index space if the symbol is a dup or is overwritten. In this CL, we stop reserving index spaces. Instead, symbols are added one at a time, and only added if it does not already exist. There is no more holes in the index space. Change-Id: I3c4e67163c556ba1198e13065706510dac4692fb Reviewed-on: https://go-review.googlesource.com/c/go/+/217519 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-01-31[dev.link] cmd/link: make symbol's global index uniqueCherry Zhang
Currently, when mapping symbol's local index to global index, for duplicated and overwriting/overwritten symbols, each appearance of the symbol gets a global index, with one being the "primary", and others "redirect" to it through the overwrite map. Basically, the local-global index mapping is one to one, with overwrite/ dedup happening in global index level. This has a few drawbacks: - All symbol accesses effectively need to query the overwrite map. This may hurt performance. - For multi-level overwrites, (Y overwrites X, Z overwrites Y), this can get quite complicated, and we have to follow the redirection recursively. - Failed to follow or to update the overwrite map leads to bugs. In this CL, we change the index mapping mechanism so that each symbol get a unique global index. Multiple appearances of the same symbol get the same index. Now the local-global index mapping is N to one. Overwrite/dedup happens directly in the local-global mapping. We keep both mapping directions in arrays. Each object carries an array for its local-global mapping. The loader carries an array mapping global index to the "primary" local index, which is the one we should load from. This way, we can get rid of the overwrite map, and index conversions are simply array accesses. TODO: we still make reservation of the index space upfront, and leave holes for dup symbols. Maybe get rid of the reservation and holes. Change-Id: Ia251489d5f2ff16a0b3156a71d141a70cdf03a4e Reviewed-on: https://go-review.googlesource.com/c/go/+/217064 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-01-31[dev.link] cmd/link: fix payload pointer livenessCherry Zhang
Currently, the symbol updater uses a pointer pointing to the loader's payloads array. If the payloads slice grows (and moves), the pointer may become stale and no longer point to the symbol's actual payload. Specifically, consider sb, sym := l.MakeSymbolUpdater(...) // add a bunch of external symbols, which grows payload slice sb.SetType(t) l.SymType(sym) // may not return t sb.SetType on line 3 may not have the desired effect, as sb.extSymPayload may no longer point to the right payload. As a result, the type we get on line 4 may be not the one we set. Fix this by making the payload's address permanent. Once it is allocated it will never move. Change-Id: Iab190ea5aceb5c37f91d09ad4ffd458e881b03f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/217063 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-01-06[dev.link] cmd/link: support updates to contents of obj-based SymsThan McIntosh
Add in the hooks to SymbolBuilder and to the loader to allow the linker to make modifications to a non-external symbol (e.g. a sym whose index is less than loader.extStart). The basic idea is to manufacture a new external symbol with the same name and version, then import the old symbol's content (type, data, relocations, etc) into the payload struct for the new symbol, and finally redirect the name lookup tables to target the new sym for the specified name/version. This change is needed in order to convert over the host object loaders to avoid use of sym.Symbol. Change-Id: I79cd42b23794e830bbdbcbcd2c500c35c351f01f Reviewed-on: https://go-review.googlesource.com/c/go/+/211897 Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-12-27[dev.link] cmd/link: add SymbolBuilder helperThan McIntosh
Add SymbolBuilder helper type -- this type provides a set of methods intended to make it easy to manipulate the content of a symbol (type, relocations, data, etc). Change-Id: I579bf8d04650e66d33a9780a6c2347a576c94c6f Reviewed-on: https://go-review.googlesource.com/c/go/+/210178 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-12-20[dev.link] cmd/link: record external symbol alignmentThan McIntosh
Add a mechanism for recording symbol alignment for external symbols under the new loader scheme. Alignments is stored in a side table, since most symbols don't wind up needing an alignment other than zero. Change-Id: I97092481412c15eac9b9f4c29b5c273f53759562 Reviewed-on: https://go-review.googlesource.com/c/go/+/210177 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-12-20[dev.link] cmd/link: add loader method to sort sub-symbols of outer symbolThan McIntosh
Add a new loader method SymSortSub that sorts the sub-symbols of a given outer symbol (designed to be compatible with the existing sym.Symbol method). Change-Id: Icd6627b2e6d04524d657e712cfd39fda0e0e080b Reviewed-on: https://go-review.googlesource.com/c/go/+/211297 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-12-18[dev.link] cmd/link: support marking outer/sub for external loader.SymThan McIntosh
Add a loader mechanism for recording outer/sub relationships between symbols without falling back on sym.Symbol. Also includes a new "PrependSub" method that provides a way to chain a sub-symbol only the list of an outer symbol (a common operation when manipulating outer/sub relationships in the linker). Change-Id: I70c72356945ceec2bacdcdc25bcc352bfb6765a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/210777 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>
2019-12-18[dev.link] cmd/link: add storage and methods for read/write of Sym valueThan McIntosh
Add loader methods SymValue() and SetSymValue() to get/set the value of a symbol by global index. Change-Id: Ifc71480fc34c719ad00506d0828edf36c1a57119 Reviewed-on: https://go-review.googlesource.com/c/go/+/211302 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>
2019-12-18[dev.link] cmd/link: expand set of symbol attributes in loaderThan McIntosh
Add in a collection of new loader interfaces for getting/setting symbol attributes, e.g. properties that would normally be part of the sym.Symbol "Attr" field. This change also moves references to the loaders 'reachable' bitmap behind a pair of loader methods, so that we a consistent way of accessing symbol attributes overall. It is worth noting that not every symbol attribute is backed by a bitmap; for some infrequently used attributes, a map[Sym]struct{} is used instead. Change-Id: I0010c9cd928d41b4bb6cdf45db4581e11c3c5db3 Reviewed-on: https://go-review.googlesource.com/c/go/+/210778 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>
2019-12-18[dev.link] cmd/link: initial support for linker-materialized external symbolsThan McIntosh
Create loader infrastructure for constructing the payloads of external symbols from scratch, as opposed to passing in a sym.Symbol object containing the payload. The general idea is that clients can use the loader to create new external Sym's using loader.AddExtSym, and then can add relocations/data to the new sym with symbol builder interfaces (to be provided in an subsequent patch), as opposed to having to use sym.Symbol. This change preserves compatibility with the old way of doing things (passing in sym.Symbol) via a new loader.InstallSym method. If a client invokes this method for a specific Sym, then the loader keeps track of this fact and uses the sym.Symbol as the backing store instead. Also included is a small unit test for the new interfaces -- not clear whether this really needs to be kept around long term... it was mainly useful during initial bringup. Change-Id: If8ab15df7b64636e56b317155dfe6d7cdfe23b71 Reviewed-on: https://go-review.googlesource.com/c/go/+/207606 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>