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>
}
// For use with pass.c::genasmsym
-func defdwsymb(ctxt *Link, sym *Symbol, s string, t int, v int64, size int64, ver int, gotype *Symbol) {
+func defdwsymb(ctxt *Link, sym *Symbol, s string, t SymbolType, v int64, size int64, ver int, gotype *Symbol) {
if strings.HasPrefix(s, "go.string.") {
return
}
default:
return
- case 'd', 'b', 'D', 'B':
+ case DataSym, BSSSym:
dv = newdie(ctxt, &dwglobals, dwarf.DW_ABRV_VARIABLE, s, ver)
newabslocexprattr(dv, v, sym)
if ver == 0 {
}
fallthrough
- case 'a', 'p':
+ case AutoSym, ParamSym:
dt = defgotype(ctxt, gotype)
}
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 {
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() {
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
// 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
}
}
return SymKindLocal
}
-func addsym(ctxt *Link, s *Symbol, name string, type_ int, addr int64, size int64, ver int, gotype *Symbol) {
+func addsym(ctxt *Link, s *Symbol, name string, type_ SymbolType, addr int64, size int64, ver int, gotype *Symbol) {
if s == nil {
return
}
default:
return
- case 'D', 'B', 'T':
+ case DataSym, BSSSym, TextSym:
break
}
return s1.Extname < s2.Extname
}
-func machogenasmsym(ctxt *Link, put func(*Link, *Symbol, string, int, int64, int64, int, *Symbol)) {
- genasmsym(ctxt, put)
+func machogenasmsym(ctxt *Link) {
+ genasmsym(ctxt, addsym)
for _, s := range ctxt.Allsym {
if s.Type == obj.SDYNIMPORT || s.Type == obj.SHOSTOBJ {
if s.Attr.Reachable() {
- put(ctxt, s, "", 'D', 0, 0, 0, nil)
+ addsym(ctxt, s, "", DataSym, 0, 0, 0, nil)
}
}
}
for i := 0; i < len(dynexp); i++ {
dynexp[i].Attr |= AttrReachable
}
- machogenasmsym(ctxt, addsym)
+ machogenasmsym(ctxt)
sortsym = make([]*Symbol, nsortsym)
nsortsym = 0
- machogenasmsym(ctxt, addsym)
+ machogenasmsym(ctxt)
sort.Sort(machoscmp(sortsym[:nsortsym]))
for i := 0; i < nsortsym; i++ {
sortsym[i].Dynid = int32(i)
func writePESymTableRecords(ctxt *Link) int {
var symcnt int
- put := func(ctxt *Link, s *Symbol, name string, type_ int, addr int64, size int64, ver int, gotype *Symbol) {
+ put := func(ctxt *Link, s *Symbol, name string, type_ SymbolType, addr int64, size int64, ver int, gotype *Symbol) {
if s == nil {
return
}
- if s.Sect == nil && type_ != 'U' {
+ if s.Sect == nil && type_ != UndefinedSym {
return
}
switch type_ {
default:
return
- case 'D', 'B', 'T', 'U':
+ case DataSym, BSSSym, TextSym, UndefinedSym:
}
// only windows/386 requires underscore prefix on external symbols
} else if uint64(s.Value) >= Segtext.Vaddr {
value = int64(uint64(s.Value) - Segtext.Vaddr)
sect = textsect
- } else if type_ == 'U' {
+ } else if type_ == UndefinedSym {
typ = IMAGE_SYM_DTYPE_FUNCTION
} else {
ctxt.Diag("addpesym %#x", addr)
for d := dr; d != nil; d = d.next {
for m := d.ms; m != nil; m = m.next {
s := m.s.R[0].Xsym
- put(ctxt, s, s.Name, 'U', 0, int64(SysArch.PtrSize), 0, nil)
+ put(ctxt, s, s.Name, UndefinedSym, 0, int64(SysArch.PtrSize), 0, nil)
}
}
s := Linklookup(ctxt, ".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)
}
}
var elfbind int
-func putelfsym(ctxt *Link, x *Symbol, s string, t int, addr int64, size int64, ver int, go_ *Symbol) {
- var type_ int
+func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, size int64, ver int, go_ *Symbol) {
+ var typ int
switch t {
default:
return
- case 'T':
- type_ = STT_FUNC
+ case TextSym:
+ typ = STT_FUNC
- case 'D':
- type_ = STT_OBJECT
+ case DataSym, BSSSym:
+ typ = STT_OBJECT
- case 'B':
- type_ = STT_OBJECT
-
- case 'U':
+ case UndefinedSym:
// ElfType is only set for symbols read from Go shared libraries, but
// for other symbols it is left as STT_NOTYPE which is fine.
- type_ = int(x.ElfType)
+ typ = int(x.ElfType)
- case 't':
- type_ = STT_TLS
+ case TLSSym:
+ typ = STT_TLS
}
xo := x
if x.Type&obj.SHIDDEN != 0 {
other = STV_HIDDEN
}
- if (Buildmode == BuildmodeCArchive || Buildmode == BuildmodePIE || ctxt.DynlinkingGo()) && SysArch.Family == sys.PPC64 && type_ == STT_FUNC && x.Name != "runtime.duffzero" && x.Name != "runtime.duffcopy" {
+ if (Buildmode == BuildmodeCArchive || Buildmode == BuildmodePIE || ctxt.DynlinkingGo()) && SysArch.Family == sys.PPC64 && typ == STT_FUNC && x.Name != "runtime.duffzero" && x.Name != "runtime.duffcopy" {
// On ppc64 the top three bits of the st_other field indicate how
// many instructions separate the global and local entry points. In
// our case it is two instructions, indicated by the value 3.
// (*Symbol).ElfsymForReloc). This is approximately equivalent to the
// ELF linker -Bsymbolic-functions option, but that is buggy on
// several platforms.
- putelfsyment(putelfstr("local."+s), addr, size, STB_LOCAL<<4|type_&0xf, elfshnum, other)
+ putelfsyment(putelfstr("local."+s), addr, size, STB_LOCAL<<4|typ&0xf, elfshnum, other)
x.LocalElfsym = int32(numelfsym)
numelfsym++
return
return
}
- putelfsyment(putelfstr(s), addr, size, bind<<4|type_&0xf, elfshnum, other)
+ putelfsyment(putelfstr(s), addr, size, bind<<4|typ&0xf, elfshnum, other)
x.Elfsym = int32(numelfsym)
numelfsym++
}
genasmsym(ctxt, putelfsym)
}
-func putplan9sym(ctxt *Link, x *Symbol, s string, t int, addr int64, size int64, ver int, go_ *Symbol) {
- switch t {
- case 'T', 'L', 'D', 'B':
+func putplan9sym(ctxt *Link, x *Symbol, s string, typ SymbolType, addr int64, size int64, ver int, go_ *Symbol) {
+ t := int(typ)
+ switch typ {
+ case TextSym, DataSym, BSSSym:
if ver != 0 {
t += 'a' - 'A'
}
fallthrough
- case 'a',
- 'p',
- 'f',
- 'z',
- 'Z',
- 'm':
+ case AutoSym, ParamSym, FileSym, FrameSym:
l := 4
if Headtype == obj.Hplan9 && SysArch.Family == sys.AMD64 && !Flag8 {
Lputb(uint32(addr >> 32))
Cput(uint8(t + 0x80)) /* 0x80 is variable length */
var i int
- if t == 'z' || t == 'Z' {
- Cput(s[0])
- for i = 1; s[i] != 0 || s[i+1] != 0; i += 2 {
- Cput(s[i])
- Cput(s[i+1])
- }
- Cput(0)
- Cput(0)
- i++
- } else {
- /* skip the '<' in filenames */
- if t == 'f' {
- s = s[1:]
- }
- for i = 0; i < len(s); i++ {
- Cput(s[i])
- }
- Cput(0)
+ /* skip the '<' in filenames */
+ if t == FileSym {
+ s = s[1:]
+ }
+ for i = 0; i < len(s); i++ {
+ Cput(s[i])
}
+ Cput(0)
Symsize += int32(l) + 1 + int32(i) + 1