]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: convert Link.Filesyms into a slice
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Thu, 21 Apr 2016 22:10:08 +0000 (10:10 +1200)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Thu, 21 Apr 2016 22:44:09 +0000 (22:44 +0000)
Change-Id: I6490de325b0f4ba962c679503102d30d41dcc384
Reviewed-on: https://go-review.googlesource.com/22359
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/link.go
src/cmd/link/internal/ld/pcln.go
src/cmd/link/internal/ld/symtab.go

index a5e26b49f22a8a548c7316a9dd2cbbcb133d05af..0202df664a93630d656522c17254e471ee2bf7c0 100644 (file)
@@ -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)
index a3b8e57ee5e8b78db69890283690e6094194e5ba..d0515d461719dcdec13ea8c03eacea3491c376d8 100644 (file)
@@ -179,8 +179,7 @@ type Link struct {
        Cursym     *LSym
        Version    int
        Textp      []*LSym
-       Nhistfile  int32
-       Filesyms   *LSym
+       Filesyms   []*LSym
        Moduledata *LSym
        LSymBatch  []LSym
 }
index 7d1858c95eab9ba09b0a4ed93f59786f710282e5..991b9ef2cd40df07a5f31144aec1134b06bda3a1 100644 (file)
@@ -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)))
        }
 
index 1f07a4eb77b63f26cc64f2763978c4a63068fce9..acc238f69829beb0c92857be89c61419205e29ab 100644 (file)
@@ -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