cmd/link: give names and a type to the symbol types used by genasmsym

Doing this revealed some dead code.

Change-Id: I5202fcc3f73e3dfddfea3ec7b772e16da51195da
Reviewed-on: https://go-review.googlesource.com/29331
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Michael Hudson-Doyle 2016-09-16 16:22:08 +12:00
parent c1bee49cac
commit 2266047556
5 changed files with 68 additions and 72 deletions

View file

@ -1804,16 +1804,30 @@ func doversion() {
Exitf("version %s", obj.Version)
}
func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, int, int64, int64, int, *Symbol)) {
type SymbolType int8
const (
TextSym SymbolType = 'T'
DataSym = 'D'
BSSSym = 'B'
UndefinedSym = 'U'
TLSSym = 't'
FileSym = 'f'
FrameSym = 'm'
ParamSym = 'p'
AutoSym = 'a'
)
func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, int64, int, *Symbol)) {
// These symbols won't show up in the first loop below because we
// skip STEXT symbols. Normal STEXT symbols are emitted by walking textp.
s := Linklookup(ctxt, "runtime.text", 0)
if s.Type == obj.STEXT {
put(ctxt, s, s.Name, 'T', s.Value, s.Size, int(s.Version), nil)
put(ctxt, s, s.Name, TextSym, s.Value, s.Size, int(s.Version), nil)
}
s = Linklookup(ctxt, "runtime.etext", 0)
if s.Type == obj.STEXT {
put(ctxt, s, s.Name, 'T', s.Value, s.Size, int(s.Version), nil)
put(ctxt, s, s.Name, TextSym, s.Value, s.Size, int(s.Version), nil)
}
for _, s := range ctxt.Allsym {
@ -1852,7 +1866,7 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, int, int64, int64, i
if !s.Attr.Reachable() {
continue
}
put(ctxt, s, s.Name, 'D', Symaddr(ctxt, s), s.Size, int(s.Version), s.Gotype)
put(ctxt, s, s.Name, DataSym, Symaddr(ctxt, s), s.Size, int(s.Version), s.Gotype)
case obj.SBSS, obj.SNOPTRBSS:
if !s.Attr.Reachable() {
@ -1861,39 +1875,39 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, int, int64, int64, i
if len(s.P) > 0 {
ctxt.Diag("%s should not be bss (size=%d type=%d special=%v)", s.Name, len(s.P), s.Type, s.Attr.Special())
}
put(ctxt, s, s.Name, 'B', Symaddr(ctxt, s), s.Size, int(s.Version), s.Gotype)
put(ctxt, s, s.Name, BSSSym, Symaddr(ctxt, s), s.Size, int(s.Version), s.Gotype)
case obj.SFILE:
put(ctxt, nil, s.Name, 'f', s.Value, 0, int(s.Version), nil)
put(ctxt, nil, s.Name, FileSym, s.Value, 0, int(s.Version), nil)
case obj.SHOSTOBJ:
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui || Iself {
put(ctxt, s, s.Name, 'U', s.Value, 0, int(s.Version), nil)
put(ctxt, s, s.Name, UndefinedSym, s.Value, 0, int(s.Version), nil)
}
case obj.SDYNIMPORT:
if !s.Attr.Reachable() {
continue
}
put(ctxt, s, s.Extname, 'U', 0, 0, int(s.Version), nil)
put(ctxt, s, s.Extname, UndefinedSym, 0, 0, int(s.Version), nil)
case obj.STLSBSS:
if Linkmode == LinkExternal && Headtype != obj.Hopenbsd {
put(ctxt, s, s.Name, 't', Symaddr(ctxt, s), s.Size, int(s.Version), s.Gotype)
put(ctxt, s, s.Name, TLSSym, Symaddr(ctxt, s), s.Size, int(s.Version), s.Gotype)
}
}
}
var off int32
for _, s := range ctxt.Textp {
put(ctxt, s, s.Name, 'T', s.Value, s.Size, int(s.Version), s.Gotype)
put(ctxt, s, s.Name, TextSym, s.Value, s.Size, int(s.Version), s.Gotype)
locals := int32(0)
if s.FuncInfo != nil {
locals = s.FuncInfo.Locals
}
// NOTE(ality): acid can't produce a stack trace without .frame symbols
put(ctxt, nil, ".frame", 'm', int64(locals)+int64(SysArch.PtrSize), 0, 0, nil)
put(ctxt, nil, ".frame", FrameSym, int64(locals)+int64(SysArch.PtrSize), 0, 0, nil)
if s.FuncInfo == nil {
continue
@ -1914,13 +1928,13 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, int, int64, int64, i
// FP
if off >= 0 {
put(ctxt, nil, a.Asym.Name, 'p', int64(off), 0, 0, a.Gotype)
put(ctxt, nil, a.Asym.Name, ParamSym, int64(off), 0, 0, a.Gotype)
continue
}
// SP
if off <= int32(-SysArch.PtrSize) {
put(ctxt, nil, a.Asym.Name, 'a', -(int64(off) + int64(SysArch.PtrSize)), 0, 0, a.Gotype)
put(ctxt, nil, a.Asym.Name, AutoSym, -(int64(off) + int64(SysArch.PtrSize)), 0, 0, a.Gotype)
continue
}
}