cmd/internal/objabi, cmd/link: move linker-only symkind values into linker

Many (most!) of the values of objapi.SymKind are used only in the linker, so
this creates a separate cmd/link/internal/ld.SymKind type, removes most values
from SymKind and maps one to the other when reading object files in the linker.

Two of the remaining objapi.SymKind values are only checked for, never set and
so will never be actually found but I wanted to keep this to the most
mechanical change possible.

Change-Id: I4bbc5aed6713cab3e8de732e6e288eb77be0474c
Reviewed-on: https://go-review.googlesource.com/40985
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Michael Hudson-Doyle 2017-04-19 15:15:35 +12:00
parent b1868cf107
commit be2ee2a4b4
31 changed files with 642 additions and 549 deletions

View file

@ -45,15 +45,15 @@ func (f *goobjFile) symbols() ([]Sym, error) {
seen[s.SymID] = true
sym := Sym{Addr: uint64(s.Data.Offset), Name: goobjName(s.SymID), Size: int64(s.Size), Type: s.Type.Name, Code: '?'}
switch s.Kind {
case objabi.STEXT, objabi.SELFRXSECT:
case objabi.STEXT:
sym.Code = 'T'
case objabi.STYPE, objabi.SSTRING, objabi.SGOSTRING, objabi.SGOFUNC, objabi.SRODATA, objabi.SFUNCTAB, objabi.STYPELINK, objabi.SITABLINK, objabi.SSYMTAB, objabi.SPCLNTAB, objabi.SELFROSECT:
case objabi.SRODATA:
sym.Code = 'R'
case objabi.SMACHOPLT, objabi.SELFSECT, objabi.SMACHO, objabi.SMACHOGOT, objabi.SNOPTRDATA, objabi.SINITARR, objabi.SDATA, objabi.SWINDOWS:
case objabi.SDATA:
sym.Code = 'D'
case objabi.SBSS, objabi.SNOPTRBSS, objabi.STLSBSS:
sym.Code = 'B'
case objabi.SXREF, objabi.SMACHOSYMSTR, objabi.SMACHOSYMTAB, objabi.SMACHOINDIRECTPLT, objabi.SMACHOINDIRECTGOT, objabi.SFILE, objabi.SFILEPATH, objabi.SCONST, objabi.SDYNIMPORT, objabi.SHOSTOBJ:
case objabi.SXREF, objabi.SCONST:
sym.Code = 'X' // should not see
}
if s.Version != 0 {