mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/compile, cmd/link: reference type symbol of defined type by index
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>
This commit is contained in:
parent
e4e1c6a7af
commit
69748f0ce4
6 changed files with 137 additions and 12 deletions
|
|
@ -2149,6 +2149,7 @@ func (l *Loader) LoadNonpkgSyms(arch *sys.Arch) {
|
|||
}
|
||||
|
||||
func loadObjRefs(l *Loader, r *oReader, arch *sys.Arch) {
|
||||
// load non-package refs
|
||||
ndef := uint32(r.NAlldef())
|
||||
needNameExpansion := r.NeedNameExpansion()
|
||||
for i, n := uint32(0), uint32(r.NNonpkgref()); i < n; i++ {
|
||||
|
|
@ -2167,6 +2168,15 @@ func loadObjRefs(l *Loader, r *oReader, arch *sys.Arch) {
|
|||
l.SetAttrUsedInIface(gi, true)
|
||||
}
|
||||
}
|
||||
|
||||
// load flags of package refs
|
||||
for i, n := 0, r.NRefFlags(); i < n; i++ {
|
||||
rf := r.RefFlags(i)
|
||||
gi := l.resolve(r, rf.Sym())
|
||||
if rf.Flag2()&goobj2.SymFlagUsedInIface != 0 {
|
||||
l.SetAttrUsedInIface(gi, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func abiToVer(abi uint16, localSymVersion int) int {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue