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 {
Adduint8(Ctxt, ls, 1) // standard_opcode_lengths[9]
Adduint8(Ctxt, ls, 0) // include_directories (empty)
files := make([]*LSym, Ctxt.Nhistfile)
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)
for _, f := range Ctxt.Filesyms {
Addstring(ls, f.Name)
Adduint8(Ctxt, ls, 0)
Adduint8(Ctxt, ls, 0)
Adduint8(Ctxt, ls, 0)
......
......@@ -179,8 +179,7 @@ type Link struct {
Cursym *LSym
Version int
Textp []*LSym
Nhistfile int32
Filesyms *LSym
Filesyms []*LSym
Moduledata *LSym
LSymBatch []LSym
}
......
......@@ -147,12 +147,10 @@ func renumberfiles(ctxt *Link, files []*LSym, d *Pcdata) {
for i := 0; i < len(files); i++ {
f = files[i]
if f.Type != obj.SFILEPATH {
ctxt.Nhistfile++
f.Value = int64(ctxt.Nhistfile)
ctxt.Filesyms = append(ctxt.Filesyms, f)
f.Value = int64(len(ctxt.Filesyms))
f.Type = obj.SFILEPATH
f.Next = ctxt.Filesyms
f.Name = expandGoroot(f.Name)
ctxt.Filesyms = f
}
}
......@@ -302,8 +300,8 @@ func pclntab() {
// Sanity check the new numbering
var it Pciter
for pciterinit(Ctxt, &it, &pcln.Pcfile); it.done == 0; pciternext(&it) {
if it.value < 1 || it.value > Ctxt.Nhistfile {
Diag("bad file number in pcfile: %d not in range [1, %d]\n", 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, len(Ctxt.Filesyms))
errorexit()
}
}
......@@ -360,9 +358,10 @@ func pclntab() {
pclntabFiletabOffset = 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)
setuint32(Ctxt, ftab, int64(start), uint32(Ctxt.Nhistfile))
for s := Ctxt.Filesyms; s != nil; s = s.Next {
Symgrow(Ctxt, ftab, int64(start)+(int64(len(Ctxt.Filesyms))+1)*4)
setuint32(Ctxt, ftab, int64(start), uint32(len(Ctxt.Filesyms)))
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)))
}
......
......@@ -499,8 +499,8 @@ func symtab() {
adduint(Ctxt, moduledata, uint64(pclntabNfunc+1))
// The filetab slice
Addaddrplus(Ctxt, moduledata, Linklookup(Ctxt, "runtime.pclntab", 0), int64(pclntabFiletabOffset))
adduint(Ctxt, moduledata, uint64(Ctxt.Nhistfile)+1)
adduint(Ctxt, moduledata, uint64(Ctxt.Nhistfile)+1)
adduint(Ctxt, moduledata, uint64(len(Ctxt.Filesyms))+1)
adduint(Ctxt, moduledata, uint64(len(Ctxt.Filesyms))+1)
// findfunctab
Addaddr(Ctxt, moduledata, Linklookup(Ctxt, "runtime.findfunctab", 0))
// 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