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