cmd/link: convert textp into a slice

Updates #15374

Change-Id: I3ea715735862fe9550b88d7a29def6cb9d4419a6
Reviewed-on: https://go-review.googlesource.com/22243
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
This commit is contained in:
David Crawshaw 2016-04-19 14:02:21 -04:00
parent 5a0881a1d1
commit 7d56215bcb
19 changed files with 71 additions and 168 deletions

View file

@ -1545,30 +1545,14 @@ func ldshlibsyms(shlib string) {
// We might have overwritten some functions above (this tends to happen for the
// autogenerated type equality/hashing functions) and we don't want to generated
// pcln table entries for these any more so unstitch them from the Textp linked
// list.
var last *LSym
for s := Ctxt.Textp; s != nil; s = s.Next {
if s.Type == obj.SDYNIMPORT {
continue
// pcln table entries for these any more so remove them from Textp.
textp := make([]*LSym, 0, len(Ctxt.Textp))
for _, s := range Ctxt.Textp {
if s.Type != obj.SDYNIMPORT {
textp = append(textp, s)
}
if last == nil {
Ctxt.Textp = s
} else {
last.Next = s
}
last = s
}
if last == nil {
Ctxt.Textp = nil
Ctxt.Etextp = nil
} else {
last.Next = nil
Ctxt.Etextp = last
}
Ctxt.Textp = textp
Ctxt.Shlibs = append(Ctxt.Shlibs, Shlib{Path: libpath, Hash: hash, Deps: deps, File: f, gcdata_addresses: gcdata_addresses})
}
@ -1682,7 +1666,7 @@ func dostkcheck() {
// Check every function, but do the nosplit functions in a first pass,
// to make the printed failure chains as short as possible.
for s := Ctxt.Textp; s != nil; s = s.Next {
for _, s := range Ctxt.Textp {
// runtime.racesymbolizethunk is called from gcc-compiled C
// code running on the operating system thread stack.
// It uses more than the usual amount of stack but that's okay.
@ -1697,7 +1681,7 @@ func dostkcheck() {
}
}
for s := Ctxt.Textp; s != nil; s = s.Next {
for _, s := range Ctxt.Textp {
if !s.Attr.NoSplit() {
Ctxt.Cursym = s
ch.sym = s
@ -1995,7 +1979,7 @@ func genasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) {
}
var off int32
for s := Ctxt.Textp; s != nil; s = s.Next {
for _, s := range Ctxt.Textp {
put(s, s.Name, 'T', s.Value, s.Size, int(s.Version), s.Gotype)
locals := int32(0)
@ -2105,7 +2089,7 @@ func undefsym(s *LSym) {
}
func undef() {
for s := Ctxt.Textp; s != nil; s = s.Next {
for _, s := range Ctxt.Textp {
undefsym(s)
}
for _, s := range datap {
@ -2123,7 +2107,7 @@ func callgraph() {
var i int
var r *Reloc
for s := Ctxt.Textp; s != nil; s = s.Next {
for _, s := range Ctxt.Textp {
for i = 0; i < len(s.R); i++ {
r = &s.R[i]
if r.Sym == nil {