Commit 25d95ee9 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

cmd/link: convert Link.Filesyms into a slice

Change-Id: I6490de325b0f4ba962c679503102d30d41dcc384
Reviewed-on: https://go-review.googlesource.com/22359
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 4b175fd2
...@@ -1469,14 +1469,8 @@ func writelines(prev *LSym) *LSym { ...@@ -1469,14 +1469,8 @@ func writelines(prev *LSym) *LSym {
Adduint8(Ctxt, ls, 1) // standard_opcode_lengths[9] Adduint8(Ctxt, ls, 1) // standard_opcode_lengths[9]
Adduint8(Ctxt, ls, 0) // include_directories (empty) Adduint8(Ctxt, ls, 0) // include_directories (empty)
files := make([]*LSym, Ctxt.Nhistfile) for _, f := range Ctxt.Filesyms {
Addstring(ls, f.Name)
for f := Ctxt.Filesyms; f != nil; f = f.Next {
files[f.Value-1] = f
}
for i := 0; int32(i) < Ctxt.Nhistfile; i++ {
Addstring(ls, files[i].Name)
Adduint8(Ctxt, ls, 0) Adduint8(Ctxt, ls, 0)
Adduint8(Ctxt, ls, 0) Adduint8(Ctxt, ls, 0)
Adduint8(Ctxt, ls, 0) Adduint8(Ctxt, ls, 0)
......
...@@ -179,8 +179,7 @@ type Link struct { ...@@ -179,8 +179,7 @@ type Link struct {
Cursym *LSym Cursym *LSym
Version int Version int
Textp []*LSym Textp []*LSym
Nhistfile int32 Filesyms []*LSym
Filesyms *LSym
Moduledata *LSym Moduledata *LSym
LSymBatch []LSym LSymBatch []LSym
} }
......
...@@ -147,12 +147,10 @@ func renumberfiles(ctxt *Link, files []*LSym, d *Pcdata) { ...@@ -147,12 +147,10 @@ func renumberfiles(ctxt *Link, files []*LSym, d *Pcdata) {
for i := 0; i < len(files); i++ { for i := 0; i < len(files); i++ {
f = files[i] f = files[i]
if f.Type != obj.SFILEPATH { if f.Type != obj.SFILEPATH {
ctxt.Nhistfile++ ctxt.Filesyms = append(ctxt.Filesyms, f)
f.Value = int64(ctxt.Nhistfile) f.Value = int64(len(ctxt.Filesyms))
f.Type = obj.SFILEPATH f.Type = obj.SFILEPATH
f.Next = ctxt.Filesyms
f.Name = expandGoroot(f.Name) f.Name = expandGoroot(f.Name)
ctxt.Filesyms = f
} }
} }
...@@ -302,8 +300,8 @@ func pclntab() { ...@@ -302,8 +300,8 @@ func pclntab() {
// Sanity check the new numbering // Sanity check the new numbering
var it Pciter var it Pciter
for pciterinit(Ctxt, &it, &pcln.Pcfile); it.done == 0; pciternext(&it) { for pciterinit(Ctxt, &it, &pcln.Pcfile); it.done == 0; pciternext(&it) {
if it.value < 1 || it.value > Ctxt.Nhistfile { if it.value < 1 || it.value > int32(len(Ctxt.Filesyms)) {
Diag("bad file number in pcfile: %d not in range [1, %d]\n", it.value, Ctxt.Nhistfile) Diag("bad file number in pcfile: %d not in range [1, %d]\n", it.value, len(Ctxt.Filesyms))
errorexit() errorexit()
} }
} }
...@@ -360,9 +358,10 @@ func pclntab() { ...@@ -360,9 +358,10 @@ func pclntab() {
pclntabFiletabOffset = start pclntabFiletabOffset = start
setuint32(Ctxt, ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize), uint32(start)) setuint32(Ctxt, ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize), uint32(start))
Symgrow(Ctxt, ftab, int64(start)+(int64(Ctxt.Nhistfile)+1)*4) Symgrow(Ctxt, ftab, int64(start)+(int64(len(Ctxt.Filesyms))+1)*4)
setuint32(Ctxt, ftab, int64(start), uint32(Ctxt.Nhistfile)) setuint32(Ctxt, ftab, int64(start), uint32(len(Ctxt.Filesyms)))
for s := Ctxt.Filesyms; s != nil; s = s.Next { for i := len(Ctxt.Filesyms) - 1; i >= 0; i-- {
s := Ctxt.Filesyms[i]
setuint32(Ctxt, ftab, int64(start)+s.Value*4, uint32(ftabaddstring(ftab, s.Name))) setuint32(Ctxt, ftab, int64(start)+s.Value*4, uint32(ftabaddstring(ftab, s.Name)))
} }
......
...@@ -499,8 +499,8 @@ func symtab() { ...@@ -499,8 +499,8 @@ func symtab() {
adduint(Ctxt, moduledata, uint64(pclntabNfunc+1)) adduint(Ctxt, moduledata, uint64(pclntabNfunc+1))
// The filetab slice // The filetab slice
Addaddrplus(Ctxt, moduledata, Linklookup(Ctxt, "runtime.pclntab", 0), int64(pclntabFiletabOffset)) Addaddrplus(Ctxt, moduledata, Linklookup(Ctxt, "runtime.pclntab", 0), int64(pclntabFiletabOffset))
adduint(Ctxt, moduledata, uint64(Ctxt.Nhistfile)+1) adduint(Ctxt, moduledata, uint64(len(Ctxt.Filesyms))+1)
adduint(Ctxt, moduledata, uint64(Ctxt.Nhistfile)+1) adduint(Ctxt, moduledata, uint64(len(Ctxt.Filesyms))+1)
// findfunctab // findfunctab
Addaddr(Ctxt, moduledata, Linklookup(Ctxt, "runtime.findfunctab", 0)) Addaddr(Ctxt, moduledata, Linklookup(Ctxt, "runtime.findfunctab", 0))
// minpc, maxpc // minpc, maxpc
......
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