]> Cypherpunks repositories - gostls13.git/commit
[dev.link] cmd/compile, cmd/link: reference type symbol of defined type by index
authorCherry Zhang <cherryyz@google.com>
Mon, 27 Jul 2020 18:46:16 +0000 (14:46 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 3 Aug 2020 21:11:33 +0000 (21:11 +0000)
commit69748f0ce4faf850a2e25641aed23e646556d616
tree6d24b350ee1208278d357e3ec645cf0c2ebb4356
parente4e1c6a7aff04a61a202ed1b331ffdfdff5a77cf
[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>
src/cmd/compile/internal/gc/iexport.go
src/cmd/compile/internal/gc/iimport.go
src/cmd/compile/internal/gc/reflect.go
src/cmd/internal/goobj2/objfile.go
src/cmd/internal/obj/objfile2.go
src/cmd/link/internal/loader/loader.go