Commit 1d3fae46 authored by David Crawshaw's avatar David Crawshaw

cmd/link: remove Cursym

Change-Id: I58253a6cd2d77a9319c0783afb0d92cd5a88a7f7
Reviewed-on: https://go-review.googlesource.com/29370
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 5a597e2d
...@@ -98,7 +98,6 @@ func gentext(ctxt *ld.Link) { ...@@ -98,7 +98,6 @@ func gentext(ctxt *ld.Link) {
func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
targ := r.Sym targ := r.Sym
ctxt.Cursym = s
switch r.Type { switch r.Type {
default: default:
......
...@@ -114,7 +114,6 @@ func braddoff(a int32, b int32) int32 { ...@@ -114,7 +114,6 @@ func braddoff(a int32, b int32) int32 {
func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
targ := r.Sym targ := r.Sym
ctxt.Cursym = s
switch r.Type { switch r.Type {
default: default:
...@@ -691,7 +690,6 @@ func asmb(ctxt *ld.Link) { ...@@ -691,7 +690,6 @@ func asmb(ctxt *ld.Link) {
} }
} }
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f header\n", obj.Cputime()) ctxt.Logf("%5.2f header\n", obj.Cputime())
} }
......
...@@ -499,7 +499,6 @@ func asmb(ctxt *ld.Link) { ...@@ -499,7 +499,6 @@ func asmb(ctxt *ld.Link) {
} }
} }
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f header\n", obj.Cputime()) ctxt.Logf("%5.2f header\n", obj.Cputime())
} }
......
...@@ -323,7 +323,6 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -323,7 +323,6 @@ func relocsym(ctxt *Link, s *Symbol) {
var fl int32 var fl int32
var o int64 var o int64
ctxt.Cursym = s
for ri := int32(0); ri < int32(len(s.R)); ri++ { for ri := int32(0); ri < int32(len(s.R)); ri++ {
r = &s.R[ri] r = &s.R[ri]
r.Done = 1 r.Done = 1
...@@ -549,7 +548,7 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -549,7 +548,7 @@ func relocsym(ctxt *Link, s *Symbol) {
// r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call. // r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call.
case obj.R_CALL, obj.R_GOTPCREL, obj.R_PCREL: case obj.R_CALL, obj.R_GOTPCREL, obj.R_PCREL:
if Linkmode == LinkExternal && r.Sym != nil && r.Sym.Type != obj.SCONST && (r.Sym.Sect != ctxt.Cursym.Sect || r.Type == obj.R_GOTPCREL) { if Linkmode == LinkExternal && r.Sym != nil && r.Sym.Type != obj.SCONST && (r.Sym.Sect != s.Sect || r.Type == obj.R_GOTPCREL) {
r.Done = 0 r.Done = 0
// set up addend for eventual relocation via outer symbol. // set up addend for eventual relocation via outer symbol.
...@@ -580,7 +579,7 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -580,7 +579,7 @@ func relocsym(ctxt *Link, s *Symbol) {
o -= int64(r.Off) // relative to section offset, not symbol o -= int64(r.Off) // relative to section offset, not symbol
} else if SysArch.Family == sys.ARM { } else if SysArch.Family == sys.ARM {
// see ../arm/asm.go:/machoreloc1 // see ../arm/asm.go:/machoreloc1
o += Symaddr(rs) - int64(ctxt.Cursym.Value) - int64(r.Off) o += Symaddr(rs) - int64(s.Value) - int64(r.Off)
} else { } else {
o += int64(r.Siz) o += int64(r.Siz)
} }
...@@ -622,7 +621,6 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -622,7 +621,6 @@ func relocsym(ctxt *Link, s *Symbol) {
} }
switch siz { switch siz {
default: default:
ctxt.Cursym = s
Errorf(s, "bad reloc size %#x for %s", uint32(siz), r.Sym.Name) Errorf(s, "bad reloc size %#x for %s", uint32(siz), r.Sym.Name)
fallthrough fallthrough
...@@ -842,7 +840,6 @@ func blk(ctxt *Link, syms []*Symbol, addr, size int64, pad []byte) { ...@@ -842,7 +840,6 @@ func blk(ctxt *Link, syms []*Symbol, addr, size int64, pad []byte) {
if s.Value >= eaddr { if s.Value >= eaddr {
break break
} }
ctxt.Cursym = s
if s.Value < addr { if s.Value < addr {
Errorf(s, "phase error: addr=%#x but sym=%#x type=%d", addr, s.Value, s.Type) Errorf(s, "phase error: addr=%#x but sym=%#x type=%d", addr, s.Value, s.Type)
errorexit() errorexit()
...@@ -1904,9 +1901,6 @@ func (ctxt *Link) textaddress() { ...@@ -1904,9 +1901,6 @@ func (ctxt *Link) textaddress() {
for sub := sym; sub != nil; sub = sub.Sub { for sub := sym; sub != nil; sub = sub.Sub {
sub.Value += int64(va) sub.Value += int64(va)
} }
if sym.Size == 0 && sym.Sub != nil {
ctxt.Cursym = sym
}
if sym.Size < MINFUNC { if sym.Size < MINFUNC {
va += MINFUNC // spacing required for findfunctab va += MINFUNC // spacing required for findfunctab
} else { } else {
...@@ -2060,7 +2054,6 @@ func (ctxt *Link) address() { ...@@ -2060,7 +2054,6 @@ func (ctxt *Link) address() {
) )
for _, s := range datap { for _, s := range datap {
ctxt.Cursym = s
if s.Sect != nil { if s.Sect != nil {
s.Value += int64(s.Sect.Vaddr) s.Value += int64(s.Sect.Vaddr)
} }
...@@ -2070,7 +2063,6 @@ func (ctxt *Link) address() { ...@@ -2070,7 +2063,6 @@ func (ctxt *Link) address() {
} }
for _, sym := range dwarfp { for _, sym := range dwarfp {
ctxt.Cursym = sym
if sym.Sect != nil { if sym.Sect != nil {
sym.Value += int64(sym.Sect.Vaddr) sym.Value += int64(sym.Sect.Vaddr)
} }
......
...@@ -999,8 +999,7 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) { ...@@ -999,8 +999,7 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) {
var pcfile Pciter var pcfile Pciter
var pcline Pciter var pcline Pciter
for _, ctxt.Cursym = range ctxt.Textp { for _, s := range ctxt.Textp {
s := ctxt.Cursym
epc = s.Value + s.Size epc = s.Value + s.Size
epcs = s epcs = s
...@@ -1152,8 +1151,7 @@ func writeframes(ctxt *Link, syms []*Symbol) []*Symbol { ...@@ -1152,8 +1151,7 @@ func writeframes(ctxt *Link, syms []*Symbol) []*Symbol {
var deltaBuf []byte var deltaBuf []byte
var pcsp Pciter var pcsp Pciter
for _, ctxt.Cursym = range ctxt.Textp { for _, s := range ctxt.Textp {
s := ctxt.Cursym
if s.FuncInfo == nil { if s.FuncInfo == nil {
continue continue
} }
......
...@@ -1759,8 +1759,6 @@ func elfrelocsect(ctxt *Link, sect *Section, syms []*Symbol) { ...@@ -1759,8 +1759,6 @@ func elfrelocsect(ctxt *Link, sect *Section, syms []*Symbol) {
if sym.Value >= int64(eaddr) { if sym.Value >= int64(eaddr) {
break break
} }
ctxt.Cursym = sym
for ri := 0; ri < len(sym.R); ri++ { for ri := 0; ri < len(sym.R); ri++ {
r := &sym.R[ri] r := &sym.R[ri]
if r.Done != 0 { if r.Done != 0 {
......
...@@ -189,7 +189,6 @@ type Link struct { ...@@ -189,7 +189,6 @@ type Link struct {
Shlibs []Shlib Shlibs []Shlib
Tlsoffset int Tlsoffset int
Cursym *Symbol
Version int Version int
Textp []*Symbol Textp []*Symbol
Filesyms []*Symbol Filesyms []*Symbol
......
...@@ -243,24 +243,24 @@ func (ctxt *Link) pclntab() { ...@@ -243,24 +243,24 @@ func (ctxt *Link) pclntab() {
nfunc = 0 nfunc = 0
var last *Symbol var last *Symbol
for _, ctxt.Cursym = range ctxt.Textp { for _, s := range ctxt.Textp {
last = ctxt.Cursym last = s
if container(ctxt.Cursym) != 0 { if container(s) != 0 {
continue continue
} }
pcln := ctxt.Cursym.FuncInfo pcln := s.FuncInfo
if pcln == nil { if pcln == nil {
pcln = &pclntabZpcln pcln = &pclntabZpcln
} }
if pclntabFirstFunc == nil { if pclntabFirstFunc == nil {
pclntabFirstFunc = ctxt.Cursym pclntabFirstFunc = s
} }
funcstart := int32(len(ftab.P)) funcstart := int32(len(ftab.P))
funcstart += int32(-len(ftab.P)) & (int32(SysArch.PtrSize) - 1) funcstart += int32(-len(ftab.P)) & (int32(SysArch.PtrSize) - 1)
setaddr(ctxt, ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize), ctxt.Cursym) setaddr(ctxt, ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize), s)
setuintxx(ctxt, ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize), uint64(funcstart), int64(SysArch.PtrSize)) setuintxx(ctxt, ftab, 8+int64(SysArch.PtrSize)+int64(nfunc)*2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize), uint64(funcstart), int64(SysArch.PtrSize))
// fixed size of struct, checked below // fixed size of struct, checked below
...@@ -273,16 +273,16 @@ func (ctxt *Link) pclntab() { ...@@ -273,16 +273,16 @@ func (ctxt *Link) pclntab() {
Symgrow(ctxt, ftab, int64(end)) Symgrow(ctxt, ftab, int64(end))
// entry uintptr // entry uintptr
off = int32(setaddr(ctxt, ftab, int64(off), ctxt.Cursym)) off = int32(setaddr(ctxt, ftab, int64(off), s))
// name int32 // name int32
off = int32(setuint32(ctxt, ftab, int64(off), uint32(ftabaddstring(ctxt, ftab, ctxt.Cursym.Name)))) off = int32(setuint32(ctxt, ftab, int64(off), uint32(ftabaddstring(ctxt, ftab, s.Name))))
// args int32 // args int32
// TODO: Move into funcinfo. // TODO: Move into funcinfo.
args := uint32(0) args := uint32(0)
if ctxt.Cursym.FuncInfo != nil { if s.FuncInfo != nil {
args = uint32(ctxt.Cursym.FuncInfo.Args) args = uint32(s.FuncInfo.Args)
} }
off = int32(setuint32(ctxt, ftab, int64(off), args)) off = int32(setuint32(ctxt, ftab, int64(off), args))
...@@ -300,7 +300,7 @@ func (ctxt *Link) pclntab() { ...@@ -300,7 +300,7 @@ func (ctxt *Link) pclntab() {
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 > int32(len(ctxt.Filesyms)) { if it.value < 1 || it.value > int32(len(ctxt.Filesyms)) {
Errorf(ctxt.Cursym, "bad file number in pcfile: %d not in range [1, %d]\n", it.value, len(ctxt.Filesyms)) Errorf(s, "bad file number in pcfile: %d not in range [1, %d]\n", it.value, len(ctxt.Filesyms))
errorexit() errorexit()
} }
} }
...@@ -339,7 +339,7 @@ func (ctxt *Link) pclntab() { ...@@ -339,7 +339,7 @@ func (ctxt *Link) pclntab() {
} }
if off != end { if off != end {
Errorf(ctxt.Cursym, "bad math in functab: funcstart=%d off=%d but end=%d (npcdata=%d nfuncdata=%d ptrsize=%d)", funcstart, off, end, len(pcln.Pcdata), len(pcln.Funcdata), SysArch.PtrSize) Errorf(s, "bad math in functab: funcstart=%d off=%d but end=%d (npcdata=%d nfuncdata=%d ptrsize=%d)", funcstart, off, end, len(pcln.Pcdata), len(pcln.Funcdata), SysArch.PtrSize)
errorexit() errorexit()
} }
......
...@@ -790,8 +790,6 @@ func perelocsect(ctxt *Link, sect *Section, syms []*Symbol) int { ...@@ -790,8 +790,6 @@ func perelocsect(ctxt *Link, sect *Section, syms []*Symbol) int {
if sym.Value >= int64(eaddr) { if sym.Value >= int64(eaddr) {
break break
} }
ctxt.Cursym = sym
for ri := 0; ri < len(sym.R); ri++ { for ri := 0; ri < len(sym.R); ri++ {
r := &sym.R[ri] r := &sym.R[ri]
if r.Done != 0 { if r.Done != 0 {
......
...@@ -278,7 +278,6 @@ func asmb(ctxt *ld.Link) { ...@@ -278,7 +278,6 @@ func asmb(ctxt *ld.Link) {
} }
} }
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f header\n", obj.Cputime()) ctxt.Logf("%5.2f header\n", obj.Cputime())
} }
......
...@@ -242,7 +242,6 @@ func gencallstub(ctxt *ld.Link, abicase int, stub *ld.Symbol, targ *ld.Symbol) { ...@@ -242,7 +242,6 @@ func gencallstub(ctxt *ld.Link, abicase int, stub *ld.Symbol, targ *ld.Symbol) {
func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
targ := r.Sym targ := r.Sym
ctxt.Cursym = s
switch r.Type { switch r.Type {
default: default:
...@@ -898,7 +897,6 @@ func asmb(ctxt *ld.Link) { ...@@ -898,7 +897,6 @@ func asmb(ctxt *ld.Link) {
} }
} }
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f header\n", obj.Cputime()) ctxt.Logf("%5.2f header\n", obj.Cputime())
} }
......
...@@ -575,7 +575,6 @@ func asmb(ctxt *ld.Link) { ...@@ -575,7 +575,6 @@ func asmb(ctxt *ld.Link) {
} }
} }
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f header\n", obj.Cputime()) ctxt.Logf("%5.2f header\n", obj.Cputime())
} }
......
...@@ -164,7 +164,6 @@ func gentext(ctxt *ld.Link) { ...@@ -164,7 +164,6 @@ func gentext(ctxt *ld.Link) {
func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
targ := r.Sym targ := r.Sym
ctxt.Cursym = s
switch r.Type { switch r.Type {
default: default:
......
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