Commit 66afbf10 authored by David Crawshaw's avatar David Crawshaw

cmd/link: use a switch for name prefix switching

Minor cleanup.

Change-Id: I7574f58a7e55c2bb798ebe9c7c98d36b8c258fb8
Reviewed-on: https://go-review.googlesource.com/21982
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 7d469179
...@@ -384,33 +384,19 @@ func symtab() { ...@@ -384,33 +384,19 @@ func symtab() {
symtyperel = s symtyperel = s
} }
s = Linklookup(Ctxt, "go.string.*", 0) groupSym := func(name string, t int16) *LSym {
s.Type = obj.SGOSTRING s := Linklookup(Ctxt, name, 0)
s.Attr |= AttrLocal s.Type = t
s.Size = 0
s.Attr |= AttrReachable
symgostring := s
s = Linklookup(Ctxt, "go.string.hdr.*", 0)
s.Type = obj.SGOSTRINGHDR
s.Attr |= AttrLocal
s.Size = 0 s.Size = 0
s.Attr |= AttrReachable s.Attr |= AttrLocal | AttrReachable
symgostringhdr := s return s
}
s = Linklookup(Ctxt, "go.func.*", 0) var (
s.Type = obj.SGOFUNC symgostring = groupSym("go.string.*", obj.SGOSTRING)
s.Attr |= AttrLocal symgostringhdr = groupSym("go.string.hdr.*", obj.SGOSTRINGHDR)
s.Size = 0 symgofunc = groupSym("go.func.*", obj.SGOFUNC)
s.Attr |= AttrReachable symgcbits = groupSym("runtime.gcbits.*", obj.SGCBITS)
symgofunc := s )
s = Linklookup(Ctxt, "runtime.gcbits.*", 0)
s.Type = obj.SGCBITS
s.Attr |= AttrLocal
s.Size = 0
s.Attr |= AttrReachable
symgcbits := s
symtypelink := Linklookup(Ctxt, "runtime.typelink", 0) symtypelink := Linklookup(Ctxt, "runtime.typelink", 0)
symtypelink.Type = obj.STYPELINK symtypelink.Type = obj.STYPELINK
...@@ -436,7 +422,8 @@ func symtab() { ...@@ -436,7 +422,8 @@ func symtab() {
continue continue
} }
if strings.HasPrefix(s.Name, "type.") { switch {
case strings.HasPrefix(s.Name, "type."):
if !DynlinkingGo() { if !DynlinkingGo() {
s.Attr |= AttrHidden s.Attr |= AttrHidden
} }
...@@ -447,23 +434,20 @@ func symtab() { ...@@ -447,23 +434,20 @@ func symtab() {
s.Type = obj.STYPE s.Type = obj.STYPE
s.Outer = symtype s.Outer = symtype
} }
}
if strings.HasPrefix(s.Name, "go.typelink.") { case strings.HasPrefix(s.Name, "go.typelink."):
ntypelinks++ ntypelinks++
s.Type = obj.STYPELINK s.Type = obj.STYPELINK
s.Attr |= AttrHidden s.Attr |= AttrHidden
s.Outer = symtypelink s.Outer = symtypelink
}
if strings.HasPrefix(s.Name, "go.itablink.") { case strings.HasPrefix(s.Name, "go.itablink."):
nitablinks++ nitablinks++
s.Type = obj.SITABLINK s.Type = obj.SITABLINK
s.Attr |= AttrHidden s.Attr |= AttrHidden
s.Outer = symitablink s.Outer = symitablink
}
if strings.HasPrefix(s.Name, "go.string.") { case strings.HasPrefix(s.Name, "go.string."):
s.Type = obj.SGOSTRING s.Type = obj.SGOSTRING
s.Attr |= AttrHidden s.Attr |= AttrHidden
s.Outer = symgostring s.Outer = symgostring
...@@ -471,21 +455,18 @@ func symtab() { ...@@ -471,21 +455,18 @@ func symtab() {
s.Type = obj.SGOSTRINGHDR s.Type = obj.SGOSTRINGHDR
s.Outer = symgostringhdr s.Outer = symgostringhdr
} }
}
if strings.HasPrefix(s.Name, "runtime.gcbits.") { case strings.HasPrefix(s.Name, "runtime.gcbits."):
s.Type = obj.SGCBITS s.Type = obj.SGCBITS
s.Attr |= AttrHidden s.Attr |= AttrHidden
s.Outer = symgcbits s.Outer = symgcbits
}
if strings.HasPrefix(s.Name, "go.func.") { case strings.HasPrefix(s.Name, "go.func."):
s.Type = obj.SGOFUNC s.Type = obj.SGOFUNC
s.Attr |= AttrHidden s.Attr |= AttrHidden
s.Outer = symgofunc s.Outer = symgofunc
}
if strings.HasPrefix(s.Name, "gcargs.") || strings.HasPrefix(s.Name, "gclocals.") || strings.HasPrefix(s.Name, "gclocals·") { case strings.HasPrefix(s.Name, "gcargs."), strings.HasPrefix(s.Name, "gclocals."), strings.HasPrefix(s.Name, "gclocals·"):
s.Type = obj.SGOFUNC s.Type = obj.SGOFUNC
s.Attr |= AttrHidden s.Attr |= AttrHidden
s.Outer = symgofunc s.Outer = symgofunc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment