Commit 7d56215b authored by David Crawshaw's avatar David Crawshaw

cmd/link: convert textp into a slice

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