diff options
| author | Cherry Zhang <cherryyz@google.com> | 2020-07-30 17:19:13 -0400 |
|---|---|---|
| committer | Cherry Zhang <cherryyz@google.com> | 2020-08-03 21:13:25 +0000 |
| commit | db924fd99e85e483def6dec1847d9527a93aaafb (patch) | |
| tree | ca185529f82065eabf0e80750df0c6f9b6c0303d /src/cmd/link/internal/loader/loader.go | |
| parent | f204ca305128ad1b500d3ba77aebf5509509a8fc (diff) | |
| download | go-db924fd99e85e483def6dec1847d9527a93aaafb.tar.xz | |
[dev.link] cmd/compile, cmd/link: generate itablink at link time
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>
Diffstat (limited to 'src/cmd/link/internal/loader/loader.go')
| -rw-r--r-- | src/cmd/link/internal/loader/loader.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go index 4da77c6d32..d56c748f9c 100644 --- a/src/cmd/link/internal/loader/loader.go +++ b/src/cmd/link/internal/loader/loader.go @@ -217,8 +217,7 @@ type Loader struct { align []uint8 // symbol 2^N alignment, indexed by global index - itablink map[Sym]struct{} // itablink[j] defined if j is go.itablink.* - deferReturnTramp map[Sym]bool // whether the symbol is a trampoline of a deferreturn call + deferReturnTramp map[Sym]bool // whether the symbol is a trampoline of a deferreturn call objByPkg map[string]*oReader // map package path to its Go object reader @@ -352,7 +351,6 @@ func NewLoader(flags uint32, elfsetstring elfsetstringFunc, reporter *ErrorRepor attrCgoExportDynamic: make(map[Sym]struct{}), attrCgoExportStatic: make(map[Sym]struct{}), generatedSyms: make(map[Sym]struct{}), - itablink: make(map[Sym]struct{}), deferReturnTramp: make(map[Sym]bool), extStaticSyms: make(map[nameVer]Sym), builtinSyms: make([]Sym, nbuiltin), @@ -1163,12 +1161,13 @@ func (l *Loader) IsTypelink(i Sym) bool { return l.SymAttr(i)&goobj2.SymFlagTypelink != 0 } -// Returns whether this is a "go.itablink.*" symbol. -func (l *Loader) IsItabLink(i Sym) bool { - if _, ok := l.itablink[i]; ok { - return true +// Returns whether this symbol is an itab symbol. +func (l *Loader) IsItab(i Sym) bool { + if l.IsExternal(i) { + return false } - return false + r, li := l.toLocal(i) + return r.Sym(li).IsItab() } // Return whether this is a trampoline of a deferreturn call. @@ -2139,9 +2138,6 @@ func (st *loadState) preloadSyms(r *oReader, kind int) { if osym.UsedInIface() { l.SetAttrUsedInIface(gi, true) } - if strings.HasPrefix(name, "go.itablink.") { - l.itablink[gi] = struct{}{} - } if strings.HasPrefix(name, "runtime.") || (loadingRuntimePkg && strings.HasPrefix(name, "type.")) { if bi := goobj2.BuiltinIdx(name, v); bi != -1 { |
