]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: convert textp into a slice
authorDavid Crawshaw <crawshaw@golang.org>
Tue, 19 Apr 2016 18:02:21 +0000 (14:02 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Thu, 21 Apr 2016 12:02:20 +0000 (12:02 +0000)
Updates #15374

Change-Id: I3ea715735862fe9550b88d7a29def6cb9d4419a6
Reviewed-on: https://go-review.googlesource.com/22243
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
19 files changed:
src/cmd/link/internal/amd64/asm.go
src/cmd/link/internal/arm/asm.go
src/cmd/link/internal/arm64/asm.go
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/deadcode.go
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/ldelf.go
src/cmd/link/internal/ld/ldmacho.go
src/cmd/link/internal/ld/ldpe.go
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/link.go
src/cmd/link/internal/ld/macho.go
src/cmd/link/internal/ld/objfile.go
src/cmd/link/internal/ld/pcln.go
src/cmd/link/internal/ld/pe.go
src/cmd/link/internal/ppc64/asm.go
src/cmd/link/internal/s390x/asm.go
src/cmd/link/internal/x86/asm.go

index ab96a59151475f8977e06303aa5cf32c8799f76d..cdb0354579b0e7910e91c472ae0bebcdb10cffbf 100644 (file)
@@ -86,12 +86,7 @@ func gentext() {
        Addcall(ld.Ctxt, initfunc, addmoduledata)
        //    c:        c3                      retq
        o(0xc3)
-       if ld.Ctxt.Etextp != nil {
-               ld.Ctxt.Etextp.Next = initfunc
-       } else {
-               ld.Ctxt.Textp = initfunc
-       }
-       ld.Ctxt.Etextp = initfunc
+       ld.Ctxt.Textp = append(ld.Ctxt.Textp, initfunc)
        initarray_entry := ld.Linklookup(ld.Ctxt, "go.link.addmoduledatainit", 0)
        initarray_entry.Attr |= ld.AttrReachable
        initarray_entry.Attr |= ld.AttrLocal
index 69e1d8f3173faa7f8887bb89f83e8d6a35bae768..069812fcef4855c246d27583ceff045b844c361d 100644 (file)
@@ -95,12 +95,7 @@ func gentext() {
        rel.Type = obj.R_PCREL
        rel.Add = 4
 
-       if ld.Ctxt.Etextp != nil {
-               ld.Ctxt.Etextp.Next = initfunc
-       } else {
-               ld.Ctxt.Textp = initfunc
-       }
-       ld.Ctxt.Etextp = initfunc
+       ld.Ctxt.Textp = append(ld.Ctxt.Textp, initfunc)
        initarray_entry := ld.Linklookup(ld.Ctxt, "go.link.addmoduledatainit", 0)
        initarray_entry.Attr |= ld.AttrReachable
        initarray_entry.Attr |= ld.AttrLocal
index d8ffffa15785b5cd784c9ce74d7310e3cf2c0f11..97803c9d03f024ca6cd7e6f31049ba72915ff593 100644 (file)
@@ -78,12 +78,7 @@ func gentext() {
        rel.Sym = ld.Linklookup(ld.Ctxt, "runtime.addmoduledata", 0)
        rel.Type = obj.R_CALLARM64 // Really should be R_AARCH64_JUMP26 but doesn't seem to make any difference
 
-       if ld.Ctxt.Etextp != nil {
-               ld.Ctxt.Etextp.Next = initfunc
-       } else {
-               ld.Ctxt.Textp = initfunc
-       }
-       ld.Ctxt.Etextp = initfunc
+       ld.Ctxt.Textp = append(ld.Ctxt.Textp, initfunc)
        initarray_entry := ld.Linklookup(ld.Ctxt, "go.link.addmoduledatainit", 0)
        initarray_entry.Attr |= ld.AttrReachable
        initarray_entry.Attr |= ld.AttrLocal
index 71af0e47305d9706a5f77d061ac8cc289acc16eb..8d20096dcf851a68feaed8ed019e0be60c839831 100644 (file)
@@ -648,7 +648,7 @@ func reloc() {
        }
        Bso.Flush()
 
-       for s := Ctxt.Textp; s != nil; s = s.Next {
+       for _, s := range Ctxt.Textp {
                relocsym(s)
        }
        for _, sym := range datap {
@@ -724,7 +724,7 @@ func dynreloc(data *[obj.SXREF][]*LSym) {
        }
        Bso.Flush()
 
-       for s := Ctxt.Textp; s != nil; s = s.Next {
+       for _, s := range Ctxt.Textp {
                dynrelocsym(s)
        }
        for _, syms := range data {
@@ -791,7 +791,7 @@ func Codeblk(addr int64, size int64) {
                fmt.Fprintf(Bso, "codeblk [%#x,%#x) at offset %#x\n", addr, addr+size, Cpos())
        }
 
-       blk(Ctxt.Textp, addr, size)
+       blkSlice(Ctxt.Textp, addr, size)
 
        /* again for printing */
        if Debug['a'] == 0 {
@@ -799,7 +799,7 @@ func Codeblk(addr int64, size int64) {
        }
 
        var sym *LSym
-       for sym = Ctxt.Textp; sym != nil; sym = sym.Next {
+       for _, sym = range Ctxt.Textp {
                if !sym.Attr.Reachable() {
                        continue
                }
@@ -1893,8 +1893,9 @@ func textbuildid() {
        sym.P = []byte(data)
        sym.Size = int64(len(sym.P))
 
-       sym.Next = Ctxt.Textp
-       Ctxt.Textp = sym
+       Ctxt.Textp = append(Ctxt.Textp, nil)
+       copy(Ctxt.Textp[1:], Ctxt.Textp)
+       Ctxt.Textp[0] = sym
 }
 
 // assign addresses to text
@@ -1914,7 +1915,7 @@ func textaddress() {
        }
        va := uint64(INITTEXT)
        sect.Vaddr = va
-       for sym := Ctxt.Textp; sym != nil; sym = sym.Next {
+       for _, sym := range Ctxt.Textp {
                sym.Sect = sect
                if sym.Type&obj.SSUB != 0 {
                        continue
index c83a104a546a97062db80d6d20b86f308ac8b8e4..6a70ff581fa6a8343146c9f6ddbb037f5320170c 100644 (file)
@@ -119,25 +119,13 @@ func deadcode(ctxt *Link) {
        }
 
        // Remove dead text but keep file information (z symbols).
-       var last *LSym
-       for s := ctxt.Textp; s != nil; s = s.Next {
-               if !s.Attr.Reachable() {
-                       continue
+       textp := make([]*LSym, 0, len(ctxt.Textp))
+       for _, s := range ctxt.Textp {
+               if s.Attr.Reachable() {
+                       textp = append(textp, s)
                }
-               if last == nil {
-                       ctxt.Textp = s
-               } else {
-                       last.Next = s
-               }
-               last = s
-       }
-       if last == nil {
-               ctxt.Textp = nil
-               ctxt.Etextp = nil
-       } else {
-               last.Next = nil
-               ctxt.Etextp = last
        }
+       ctxt.Textp = textp
 }
 
 var markextra = []string{
index bec9946ec5ffab316fcb8272ee63dbc6a9f2766a..a5e26b49f22a8a548c7316a9dd2cbbcb133d05af 100644 (file)
@@ -1432,7 +1432,7 @@ func writelines(prev *LSym) *LSym {
 
        lang := DW_LANG_Go
 
-       s := Ctxt.Textp
+       s := Ctxt.Textp[0]
 
        dwinfo = newdie(&dwroot, DW_ABRV_COMPUNIT, "go", 0)
        newattr(dwinfo, DW_AT_language, DW_CLS_CONSTANT, int64(lang), 0)
@@ -1502,8 +1502,8 @@ func writelines(prev *LSym) *LSym {
 
        var pcfile Pciter
        var pcline Pciter
-       for Ctxt.Cursym = Ctxt.Textp; Ctxt.Cursym != nil; Ctxt.Cursym = Ctxt.Cursym.Next {
-               s = Ctxt.Cursym
+       for _, Ctxt.Cursym = range Ctxt.Textp {
+               s := Ctxt.Cursym
 
                dwfunc := newdie(dwinfo, DW_ABRV_FUNCTION, s.Name, int(s.Version))
                newattr(dwfunc, DW_AT_low_pc, DW_CLS_ADDRESS, s.Value, s)
@@ -1696,7 +1696,7 @@ func writeframes(prev *LSym) *LSym {
 
        var deltaBuf []byte
        var pcsp Pciter
-       for Ctxt.Cursym = Ctxt.Textp; Ctxt.Cursym != nil; Ctxt.Cursym = Ctxt.Cursym.Next {
+       for _, Ctxt.Cursym = range Ctxt.Textp {
                s := Ctxt.Cursym
                if s.FuncInfo == nil {
                        continue
index 84aa58e7c76f710bd212f91ec95cb19ec747a7f7..15b8d7af93e16a28a087fcb89aeb3e7d87bb08c8 100644 (file)
@@ -1727,7 +1727,7 @@ func Elfemitreloc() {
                Cput(0)
        }
 
-       elfrelocsect(Segtext.Sect, list2slice(Ctxt.Textp))
+       elfrelocsect(Segtext.Sect, Ctxt.Textp)
        for sect := Segtext.Sect.Next; sect != nil; sect = sect.Next {
                elfrelocsect(sect, datap)
        }
index 59e71f4dd499a7073976d3ca060f043094655a76..af60a5c85b2732ef0819065582c0744b7b6c5a67 100644 (file)
@@ -842,19 +842,13 @@ func ldelf(f *bio.Reader, pkg string, length int64, pn string) {
                                log.Fatalf("symbol %s listed multiple times", s.Name)
                        }
                        s.Attr |= AttrOnList
-                       if Ctxt.Etextp != nil {
-                               Ctxt.Etextp.Next = s
-                       } else {
-                               Ctxt.Textp = s
-                       }
-                       Ctxt.Etextp = s
+                       Ctxt.Textp = append(Ctxt.Textp, s)
                        for s = s.Sub; s != nil; s = s.Sub {
                                if s.Attr.OnList() {
                                        log.Fatalf("symbol %s listed multiple times", s.Name)
                                }
                                s.Attr |= AttrOnList
-                               Ctxt.Etextp.Next = s
-                               Ctxt.Etextp = s
+                               Ctxt.Textp = append(Ctxt.Textp, s)
                        }
                }
        }
index 105fc137f90650cc8b597280106bed26747fa950..a10124907cb4808f3d3fcc9efe132ff1155853ad 100644 (file)
@@ -707,19 +707,13 @@ func ldmacho(f *bio.Reader, pkg string, length int64, pn string) {
                                log.Fatalf("symbol %s listed multiple times", s.Name)
                        }
                        s.Attr |= AttrOnList
-                       if Ctxt.Etextp != nil {
-                               Ctxt.Etextp.Next = s
-                       } else {
-                               Ctxt.Textp = s
-                       }
-                       Ctxt.Etextp = s
+                       Ctxt.Textp = append(Ctxt.Textp, s)
                        for s1 = s.Sub; s1 != nil; s1 = s1.Sub {
                                if s1.Attr.OnList() {
                                        log.Fatalf("symbol %s listed multiple times", s1.Name)
                                }
                                s1.Attr |= AttrOnList
-                               Ctxt.Etextp.Next = s1
-                               Ctxt.Etextp = s1
+                               Ctxt.Textp = append(Ctxt.Textp, s1)
                        }
                }
        }
index c51479fb4e01329ca239303f89591acfb277e907..7eb26bcbe85e11b8a35fb68831319991bce2c39f 100644 (file)
@@ -435,19 +435,13 @@ func ldpe(f *bio.Reader, pkg string, length int64, pn string) {
                                log.Fatalf("symbol %s listed multiple times", s.Name)
                        }
                        s.Attr |= AttrOnList
-                       if Ctxt.Etextp != nil {
-                               Ctxt.Etextp.Next = s
-                       } else {
-                               Ctxt.Textp = s
-                       }
-                       Ctxt.Etextp = s
+                       Ctxt.Textp = append(Ctxt.Textp, s)
                        for s = s.Sub; s != nil; s = s.Sub {
                                if s.Attr.OnList() {
                                        log.Fatalf("symbol %s listed multiple times", s.Name)
                                }
                                s.Attr |= AttrOnList
-                               Ctxt.Etextp.Next = s
-                               Ctxt.Etextp = s
+                               Ctxt.Textp = append(Ctxt.Textp, s)
                        }
                }
        }
index d728dda5b659359f7984209c70b22ce1274fd899..77db672bfdd2fe94a9a7f743ef288bb02fef756f 100644 (file)
@@ -1545,30 +1545,14 @@ func ldshlibsyms(shlib string) {
 
        // We might have overwritten some functions above (this tends to happen for the
        // autogenerated type equality/hashing functions) and we don't want to generated
-       // pcln table entries for these any more so unstitch them from the Textp linked
-       // list.
-       var last *LSym
-
-       for s := Ctxt.Textp; s != nil; s = s.Next {
-               if s.Type == obj.SDYNIMPORT {
-                       continue
-               }
-
-               if last == nil {
-                       Ctxt.Textp = s
-               } else {
-                       last.Next = s
+       // pcln table entries for these any more so remove them from Textp.
+       textp := make([]*LSym, 0, len(Ctxt.Textp))
+       for _, s := range Ctxt.Textp {
+               if s.Type != obj.SDYNIMPORT {
+                       textp = append(textp, s)
                }
-               last = s
-       }
-
-       if last == nil {
-               Ctxt.Textp = nil
-               Ctxt.Etextp = nil
-       } else {
-               last.Next = nil
-               Ctxt.Etextp = last
        }
+       Ctxt.Textp = textp
 
        Ctxt.Shlibs = append(Ctxt.Shlibs, Shlib{Path: libpath, Hash: hash, Deps: deps, File: f, gcdata_addresses: gcdata_addresses})
 }
@@ -1682,7 +1666,7 @@ func dostkcheck() {
 
        // Check every function, but do the nosplit functions in a first pass,
        // to make the printed failure chains as short as possible.
-       for s := Ctxt.Textp; s != nil; s = s.Next {
+       for _, s := range Ctxt.Textp {
                // runtime.racesymbolizethunk is called from gcc-compiled C
                // code running on the operating system thread stack.
                // It uses more than the usual amount of stack but that's okay.
@@ -1697,7 +1681,7 @@ func dostkcheck() {
                }
        }
 
-       for s := Ctxt.Textp; s != nil; s = s.Next {
+       for _, s := range Ctxt.Textp {
                if !s.Attr.NoSplit() {
                        Ctxt.Cursym = s
                        ch.sym = s
@@ -1995,7 +1979,7 @@ func genasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) {
        }
 
        var off int32
-       for s := Ctxt.Textp; s != nil; s = s.Next {
+       for _, s := range Ctxt.Textp {
                put(s, s.Name, 'T', s.Value, s.Size, int(s.Version), s.Gotype)
 
                locals := int32(0)
@@ -2105,7 +2089,7 @@ func undefsym(s *LSym) {
 }
 
 func undef() {
-       for s := Ctxt.Textp; s != nil; s = s.Next {
+       for _, s := range Ctxt.Textp {
                undefsym(s)
        }
        for _, s := range datap {
@@ -2123,7 +2107,7 @@ func callgraph() {
 
        var i int
        var r *Reloc
-       for s := Ctxt.Textp; s != nil; s = s.Next {
+       for _, s := range Ctxt.Textp {
                for i = 0; i < len(s.R); i++ {
                        r = &s.R[i]
                        if r.Sym == nil {
index b0bca4300fd4ca1b23c855c4087505d2bf981573..a3b8e57ee5e8b78db69890283690e6094194e5ba 100644 (file)
@@ -178,8 +178,7 @@ type Link struct {
        Diag       func(string, ...interface{})
        Cursym     *LSym
        Version    int
-       Textp      *LSym
-       Etextp     *LSym
+       Textp      []*LSym
        Nhistfile  int32
        Filesyms   *LSym
        Moduledata *LSym
index 5b2906ee2725c0c25c70cb5b2db769f1d8c6520b..310435e49e2b3cd53ab7c9ac9502ab4e6892e9f7 100644 (file)
@@ -852,7 +852,7 @@ func Machoemitreloc() {
                Cput(0)
        }
 
-       machorelocsect(Segtext.Sect, list2slice(Ctxt.Textp))
+       machorelocsect(Segtext.Sect, Ctxt.Textp)
        for sect := Segtext.Sect.Next; sect != nil; sect = sect.Next {
                machorelocsect(sect, datap)
        }
index 566c949040378d90c78f121daffaeb4da6efff89..bcfe52585ff084d44e31027dd8d2c2acecaa4077 100644 (file)
@@ -398,12 +398,7 @@ overwrite:
                                log.Fatalf("symbol %s listed multiple times", s.Name)
                        }
                        s.Attr |= AttrOnList
-                       if r.ctxt.Etextp != nil {
-                               r.ctxt.Etextp.Next = s
-                       } else {
-                               r.ctxt.Textp = s
-                       }
-                       r.ctxt.Etextp = s
+                       r.ctxt.Textp = append(r.ctxt.Textp, s)
                }
        }
 }
index e1c1d2d3184535de5ed4d2d125c6303aa3150c19..7d1858c95eab9ba09b0a4ed93f59786f710282e5 100644 (file)
@@ -224,14 +224,14 @@ func pclntab() {
        nfunc := int32(0)
 
        // Find container symbols, mark them with SCONTAINER
-       for Ctxt.Cursym = Ctxt.Textp; Ctxt.Cursym != nil; Ctxt.Cursym = Ctxt.Cursym.Next {
-               if Ctxt.Cursym.Outer != nil {
-                       Ctxt.Cursym.Outer.Type |= obj.SCONTAINER
+       for _, s := range Ctxt.Textp {
+               if s.Outer != nil {
+                       s.Outer.Type |= obj.SCONTAINER
                }
        }
 
-       for Ctxt.Cursym = Ctxt.Textp; Ctxt.Cursym != nil; Ctxt.Cursym = Ctxt.Cursym.Next {
-               if container(Ctxt.Cursym) == 0 {
+       for _, s := range Ctxt.Textp {
+               if container(s) == 0 {
                        nfunc++
                }
        }
@@ -246,7 +246,7 @@ func pclntab() {
 
        nfunc = 0
        var last *LSym
-       for Ctxt.Cursym = Ctxt.Textp; Ctxt.Cursym != nil; Ctxt.Cursym = Ctxt.Cursym.Next {
+       for _, Ctxt.Cursym = range Ctxt.Textp {
                last = Ctxt.Cursym
                if container(Ctxt.Cursym) != 0 {
                        continue
@@ -401,10 +401,9 @@ func findfunctab() {
        t.Attr |= AttrLocal
 
        // find min and max address
-       min := Ctxt.Textp.Value
-
+       min := Ctxt.Textp[0].Value
        max := int64(0)
-       for s := Ctxt.Textp; s != nil; s = s.Next {
+       for _, s := range Ctxt.Textp {
                max = s.Value + s.Size
        }
 
@@ -417,34 +416,34 @@ func findfunctab() {
                indexes[i] = NOIDX
        }
        idx := int32(0)
-       var e *LSym
-       var i int32
-       var p int64
-       var q int64
-       for s := Ctxt.Textp; s != nil; s = s.Next {
+       for i, s := range Ctxt.Textp {
                if container(s) != 0 {
                        continue
                }
-               p = s.Value
-               e = s.Next
-               for container(e) != 0 {
-                       e = e.Next
+               p := s.Value
+               var e *LSym
+               i++
+               if i < len(Ctxt.Textp) {
+                       e = Ctxt.Textp[i]
+               }
+               for container(e) != 0 && i < len(Ctxt.Textp) {
+                       e = Ctxt.Textp[i]
+                       i++
                }
+               q := max
                if e != nil {
                        q = e.Value
-               } else {
-                       q = max
                }
 
                //print("%d: [%lld %lld] %s\n", idx, p, q, s->name);
                for ; p < q; p += SUBBUCKETSIZE {
-                       i = int32((p - min) / SUBBUCKETSIZE)
+                       i = int((p - min) / SUBBUCKETSIZE)
                        if indexes[i] > idx {
                                indexes[i] = idx
                        }
                }
 
-               i = int32((q - 1 - min) / SUBBUCKETSIZE)
+               i = int((q - 1 - min) / SUBBUCKETSIZE)
                if indexes[i] > idx {
                        indexes[i] = idx
                }
@@ -457,15 +456,13 @@ func findfunctab() {
        Symgrow(Ctxt, t, 4*int64(nbuckets)+int64(n))
 
        // fill in table
-       var base int32
-       var j int32
        for i := int32(0); i < nbuckets; i++ {
-               base = indexes[i*SUBBUCKETS]
+               base := indexes[i*SUBBUCKETS]
                if base == NOIDX {
                        Diag("hole in findfunctab")
                }
                setuint32(Ctxt, t, int64(i)*(4+SUBBUCKETS), uint32(base))
-               for j = 0; j < SUBBUCKETS && i*SUBBUCKETS+j < n; j++ {
+               for j := int32(0); j < SUBBUCKETS && i*SUBBUCKETS+j < n; j++ {
                        idx = indexes[i*SUBBUCKETS+j]
                        if idx == NOIDX {
                                Diag("hole in findfunctab")
index c0df07d3595ad309b4b297216e8b3b113a70a04f..839aa6cca7956631087f8ff8aae0a26c1af027a5 100644 (file)
@@ -831,7 +831,7 @@ func peemitreloc(text, data, ctors *IMAGE_SECTION_HEADER) {
        Lputl(0)
        Wputl(0)
 
-       n := perelocsect(Segtext.Sect, list2slice(Ctxt.Textp)) + 1
+       n := perelocsect(Segtext.Sect, Ctxt.Textp) + 1
        for sect := Segtext.Sect.Next; sect != nil; sect = sect.Next {
                n += perelocsect(sect, datap)
        }
index 17ee25608b1244cbedb93ebba930e5575fae1e8a..dbf5fac0de0659218102bd275d9085bce7953f2e 100644 (file)
@@ -87,9 +87,7 @@ func genplt() {
        //
        // This assumes "case 1" from the ABI, where the caller needs
        // us to save and restore the TOC pointer.
-       pprevtextp := &ld.Ctxt.Textp
-
-       for s := *pprevtextp; s != nil; pprevtextp, s = &s.Next, s.Next {
+       for _, s := range ld.Ctxt.Textp {
                for i := range s.R {
                        r := &s.R[i]
                        if r.Type != 256+ld.R_PPC64_REL24 || r.Sym.Type != obj.SDYNIMPORT {
@@ -110,15 +108,7 @@ func genplt() {
                        if stub.Size == 0 {
                                // Need outer to resolve .TOC.
                                stub.Outer = s
-
-                               // Link in to textp before s (we could
-                               // do it after, but would have to skip
-                               // the subsymbols)
-                               *pprevtextp = stub
-
-                               stub.Next = s
-                               pprevtextp = &stub.Next
-
+                               ld.Ctxt.Textp = append(ld.Ctxt.Textp, stub)
                                gencallstub(1, stub, r.Sym)
                        }
 
@@ -131,7 +121,6 @@ func genplt() {
                        ld.Ctxt.Arch.ByteOrder.PutUint32(s.P[r.Off+4:], o1)
                }
        }
-
 }
 
 func genaddmoduledata() {
@@ -187,13 +176,7 @@ func genaddmoduledata() {
        // blr
        o(0x4e800020)
 
-       if ld.Ctxt.Etextp != nil {
-               ld.Ctxt.Etextp.Next = initfunc
-       } else {
-               ld.Ctxt.Textp = initfunc
-       }
-       ld.Ctxt.Etextp = initfunc
-
+       ld.Ctxt.Textp = append(ld.Ctxt.Textp, initfunc)
        initarray_entry := ld.Linklookup(ld.Ctxt, "go.link.addmoduledatainit", 0)
        initarray_entry.Attr |= ld.AttrReachable
        initarray_entry.Attr |= ld.AttrLocal
index 30b1e5a3e1746c8989ff6ed155d1a8dbd5e8c378..7c2e3358ff8a0677693227d69bdf255bbfe7a325 100644 (file)
@@ -90,12 +90,7 @@ func gentext() {
        // undef (for debugging)
        ld.Adduint32(ld.Ctxt, initfunc, 0)
 
-       if ld.Ctxt.Etextp != nil {
-               ld.Ctxt.Etextp.Next = initfunc
-       } else {
-               ld.Ctxt.Textp = initfunc
-       }
-       ld.Ctxt.Etextp = initfunc
+       ld.Ctxt.Textp = append(ld.Ctxt.Textp, initfunc)
        initarray_entry := ld.Linklookup(ld.Ctxt, "go.link.addmoduledatainit", 0)
        initarray_entry.Attr |= ld.AttrLocal
        initarray_entry.Attr |= ld.AttrReachable
index 5231ad1f6c9acf80def4181cf472cf07eed4079e..4a55b535ac60c3bbaae332bea702359b803f8772 100644 (file)
@@ -69,12 +69,7 @@ func gentext() {
        // c3           ret
        o(0xc3)
 
-       if ld.Ctxt.Etextp != nil {
-               ld.Ctxt.Etextp.Next = thunkfunc
-       } else {
-               ld.Ctxt.Textp = thunkfunc
-       }
-       ld.Ctxt.Etextp = thunkfunc
+       ld.Ctxt.Textp = append(ld.Ctxt.Textp, thunkfunc)
 
        addmoduledata := ld.Linklookup(ld.Ctxt, "runtime.addmoduledata", 0)
        if addmoduledata.Type == obj.STEXT {
@@ -130,8 +125,7 @@ func gentext() {
 
        o(0xc3)
 
-       ld.Ctxt.Etextp.Next = initfunc
-       ld.Ctxt.Etextp = initfunc
+       ld.Ctxt.Textp = append(ld.Ctxt.Textp, initfunc)
        initarray_entry := ld.Linklookup(ld.Ctxt, "go.link.addmoduledatainit", 0)
        initarray_entry.Attr |= ld.AttrReachable
        initarray_entry.Attr |= ld.AttrLocal