Commit dd2ba0c7 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/internal/obj: remove LSym.Next

Instead, use a slice.

Passes toolstash -cmp.

Change-Id: I889fdb4ae997416f907522f549b96506be13bec7
Reviewed-on: https://go-review.googlesource.com/20699Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 61b9315d
......@@ -334,7 +334,6 @@ type LSym struct {
Args int32
Locals int32
Size int64
Next *LSym
Gotype *LSym
Autom *Auto
Text *Prog
......@@ -652,10 +651,8 @@ type Link struct {
RefsWritten int // Number of symbol references already written to object file.
// state for writing objects
Text *LSym
Data *LSym
Etext *LSym
Edata *LSym
Text []*LSym
Data []*LSym
// Cache of Progs
allocIdx int
......
......@@ -130,7 +130,8 @@ func flushplist(ctxt *Link, freeProgs bool) {
// Build list of symbols, and assign instructions to lists.
// Ignore ctxt->plist boundaries. There are no guarantees there,
// and the assemblers just use one big list.
var curtext, text, etext *LSym
var curtext *LSym
var text []*LSym
for pl := ctxt.Plist; pl != nil; pl = pl.Link {
var plink *Prog
......@@ -180,12 +181,7 @@ func flushplist(ctxt *Link, freeProgs bool) {
log.Fatalf("symbol %s listed multiple times", s.Name)
}
s.Onlist = 1
if ctxt.Data == nil {
ctxt.Data = s
} else {
ctxt.Edata.Next = s
}
s.Next = nil
ctxt.Data = append(ctxt.Data, s)
s.Size = p.To.Offset
if s.Type == 0 || s.Type == SXREF {
s.Type = SBSS
......@@ -201,7 +197,6 @@ func flushplist(ctxt *Link, freeProgs bool) {
} else if flag&TLSBSS != 0 {
s.Type = STLSBSS
}
ctxt.Edata = s
continue
case ATEXT:
......@@ -220,12 +215,7 @@ func flushplist(ctxt *Link, freeProgs bool) {
log.Fatalf("symbol %s listed multiple times", s.Name)
}
s.Onlist = 1
if text == nil {
text = s
} else {
etext.Next = s
}
etext = s
text = append(text, s)
flag := int(p.From3Offset())
if flag&DUPOK != 0 {
s.Dupok = 1
......@@ -236,7 +226,6 @@ func flushplist(ctxt *Link, freeProgs bool) {
if flag&REFLECTMETHOD != 0 {
s.ReflectMethod = true
}
s.Next = nil
s.Type = STEXT
s.Text = p
s.Etext = p
......@@ -267,7 +256,7 @@ func flushplist(ctxt *Link, freeProgs bool) {
}
// Add reference to Go arguments for C or assembly functions without them.
for s := text; s != nil; s = s.Next {
for _, s := range text {
if !strings.HasPrefix(s.Name, "\"\".") {
continue
}
......@@ -292,7 +281,7 @@ func flushplist(ctxt *Link, freeProgs bool) {
}
// Turn functions into machine code images.
for s := text; s != nil; s = s.Next {
for _, s := range text {
mkfwd(s)
linkpatch(ctxt, s)
if ctxt.Flag_optimize {
......@@ -309,14 +298,7 @@ func flushplist(ctxt *Link, freeProgs bool) {
}
// Add to running list in ctxt.
if text != nil {
if ctxt.Text == nil {
ctxt.Text = text
} else {
ctxt.Etext.Next = text
}
ctxt.Etext = etext
}
ctxt.Text = append(ctxt.Text, text...)
ctxt.Plist = nil
ctxt.Plast = nil
ctxt.Curp = nil
......@@ -340,19 +322,19 @@ func Writeobjfile(ctxt *Link, b *Biobuf) {
wrstring(b, "")
// Emit symbol references.
for s := ctxt.Text; s != nil; s = s.Next {
for _, s := range ctxt.Text {
writerefs(ctxt, b, s)
}
for s := ctxt.Data; s != nil; s = s.Next {
for _, s := range ctxt.Data {
writerefs(ctxt, b, s)
}
Bputc(b, 0xff)
// Emit symbols.
for s := ctxt.Text; s != nil; s = s.Next {
for _, s := range ctxt.Text {
writesym(ctxt, b, s)
}
for s := ctxt.Data; s != nil; s = s.Next {
for _, s := range ctxt.Data {
writesym(ctxt, b, s)
}
......
......@@ -23,7 +23,7 @@ func TestSizeof(t *testing.T) {
_64bit uintptr // size on 64bit platforms
}{
{Addr{}, 52, 80},
{LSym{}, 92, 160},
{LSym{}, 88, 152},
{Prog{}, 196, 288},
}
......
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