Commit 324f6ab4 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

cmd/link: use ctxt.{Lookup,ROLookup} in favour of function versions of same

Done with two eg templates:

package p

import (
	"cmd/link/internal/ld"
)

func before(ctxt *ld.Link, name string, v int) *ld.Symbol {
	return ld.Linklookup(ctxt, name, v)
}
func after(ctxt *ld.Link, name string, v int) *ld.Symbol {
	return ctxt.Syms.Lookup(name, v)
}

package p

import (
	"cmd/link/internal/ld"
)

func before(ctxt *ld.Link, name string, v int) *ld.Symbol {
	return ld.Linkrlookup(ctxt, name, v)
}
func after(ctxt *ld.Link, name string, v int) *ld.Symbol {
	return ctxt.Syms.ROLookup(name, v)
}

Change-Id: I00647dbf62294557bd24c29ad1f108fc786335f1
Reviewed-on: https://go-review.googlesource.com/29343
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent d41a7f77
...@@ -58,14 +58,14 @@ func gentext(ctxt *ld.Link) { ...@@ -58,14 +58,14 @@ func gentext(ctxt *ld.Link) {
if !ctxt.DynlinkingGo() { if !ctxt.DynlinkingGo() {
return return
} }
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0) addmoduledata := ctxt.Syms.Lookup("runtime.addmoduledata", 0)
if addmoduledata.Type == obj.STEXT && ld.Buildmode != ld.BuildmodePlugin { if addmoduledata.Type == obj.STEXT && ld.Buildmode != ld.BuildmodePlugin {
// we're linking a module containing the runtime -> no need for // we're linking a module containing the runtime -> no need for
// an init function // an init function
return return
} }
addmoduledata.Attr |= ld.AttrReachable addmoduledata.Attr |= ld.AttrReachable
initfunc := ld.Linklookup(ctxt, "go.link.addmoduledata", 0) initfunc := ctxt.Syms.Lookup("go.link.addmoduledata", 0)
initfunc.Type = obj.STEXT initfunc.Type = obj.STEXT
initfunc.Attr |= ld.AttrLocal initfunc.Attr |= ld.AttrLocal
initfunc.Attr |= ld.AttrReachable initfunc.Attr |= ld.AttrReachable
...@@ -89,7 +89,7 @@ func gentext(ctxt *ld.Link) { ...@@ -89,7 +89,7 @@ func gentext(ctxt *ld.Link) {
if ld.Buildmode == ld.BuildmodePlugin { if ld.Buildmode == ld.BuildmodePlugin {
ctxt.Textp = append(ctxt.Textp, addmoduledata) ctxt.Textp = append(ctxt.Textp, addmoduledata)
} }
initarray_entry := ld.Linklookup(ctxt, "go.link.addmoduledatainit", 0) initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0)
initarray_entry.Attr |= ld.AttrReachable initarray_entry.Attr |= ld.AttrReachable
initarray_entry.Attr |= ld.AttrLocal initarray_entry.Attr |= ld.AttrLocal
initarray_entry.Type = obj.SINITARR initarray_entry.Type = obj.SINITARR
...@@ -123,7 +123,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -123,7 +123,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
r.Add += 4 r.Add += 4
if targ.Type == obj.SDYNIMPORT { if targ.Type == obj.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add += int64(targ.Plt) r.Add += int64(targ.Plt)
} }
...@@ -147,7 +147,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -147,7 +147,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
addgotsym(ctxt, targ) addgotsym(ctxt, targ)
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += 4 r.Add += 4
r.Add += int64(targ.Got) r.Add += int64(targ.Got)
return true return true
...@@ -174,7 +174,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -174,7 +174,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
case 512 + ld.MACHO_X86_64_RELOC_BRANCH*2 + 1: case 512 + ld.MACHO_X86_64_RELOC_BRANCH*2 + 1:
if targ.Type == obj.SDYNIMPORT { if targ.Type == obj.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(targ.Plt) r.Add = int64(targ.Plt)
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
return true return true
...@@ -216,7 +216,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -216,7 +216,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
} }
addgotsym(ctxt, targ) addgotsym(ctxt, targ)
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += int64(targ.Got) r.Add += int64(targ.Got)
return true return true
} }
...@@ -234,7 +234,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -234,7 +234,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
} else { } else {
// for both ELF and Mach-O // for both ELF and Mach-O
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(targ.Plt) r.Add = int64(targ.Plt)
return true return true
} }
...@@ -243,7 +243,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -243,7 +243,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
if s.Type == obj.STEXT && ld.Iself { if s.Type == obj.STEXT && ld.Iself {
if ld.Headtype == obj.Hsolaris { if ld.Headtype == obj.Hsolaris {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add += int64(targ.Plt) r.Add += int64(targ.Plt)
return true return true
} }
...@@ -252,7 +252,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -252,7 +252,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
// correspondent GOT symbol. // correspondent GOT symbol.
addgotsym(ctxt, targ) addgotsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += int64(targ.Got) r.Add += int64(targ.Got)
return true return true
} }
...@@ -304,7 +304,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -304,7 +304,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
// though it would be more efficient (for the dynamic linker) if we // though it would be more efficient (for the dynamic linker) if we
// generated R_X86_RELATIVE instead. // generated R_X86_RELATIVE instead.
ld.Adddynsym(ctxt, targ) ld.Adddynsym(ctxt, targ)
rela := ld.Linklookup(ctxt, ".rela", 0) rela := ctxt.Syms.Lookup(".rela", 0)
ld.Addaddrplus(ctxt, rela, s, int64(r.Off)) ld.Addaddrplus(ctxt, rela, s, int64(r.Off))
if r.Siz == 8 { if r.Siz == 8 {
ld.Adduint64(ctxt, rela, ld.ELF64_R_INFO(uint32(targ.Dynid), ld.R_X86_64_64)) ld.Adduint64(ctxt, rela, ld.ELF64_R_INFO(uint32(targ.Dynid), ld.R_X86_64_64))
...@@ -330,14 +330,14 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -330,14 +330,14 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
// but we only need to support cgo and that's all it needs. // but we only need to support cgo and that's all it needs.
ld.Adddynsym(ctxt, targ) ld.Adddynsym(ctxt, targ)
got := ld.Linklookup(ctxt, ".got", 0) got := ctxt.Syms.Lookup(".got", 0)
s.Type = got.Type | obj.SSUB s.Type = got.Type | obj.SSUB
s.Outer = got s.Outer = got
s.Sub = got.Sub s.Sub = got.Sub
got.Sub = s got.Sub = s
s.Value = got.Size s.Value = got.Size
ld.Adduint64(ctxt, got, 0) ld.Adduint64(ctxt, got, 0)
ld.Adduint32(ctxt, ld.Linklookup(ctxt, ".linkedit.got", 0), uint32(targ.Dynid)) ld.Adduint32(ctxt, ctxt.Syms.Lookup(".linkedit.got", 0), uint32(targ.Dynid))
r.Type = 256 // ignore during relocsym r.Type = 256 // ignore during relocsym
return true return true
} }
...@@ -527,8 +527,8 @@ func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 { ...@@ -527,8 +527,8 @@ func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
} }
func elfsetupplt(ctxt *ld.Link) { func elfsetupplt(ctxt *ld.Link) {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
got := ld.Linklookup(ctxt, ".got.plt", 0) got := ctxt.Syms.Lookup(".got.plt", 0)
if plt.Size == 0 { if plt.Size == 0 {
// pushq got+8(IP) // pushq got+8(IP)
ld.Adduint8(ctxt, plt, 0xff) ld.Adduint8(ctxt, plt, 0xff)
...@@ -546,7 +546,7 @@ func elfsetupplt(ctxt *ld.Link) { ...@@ -546,7 +546,7 @@ func elfsetupplt(ctxt *ld.Link) {
ld.Adduint32(ctxt, plt, 0x00401f0f) ld.Adduint32(ctxt, plt, 0x00401f0f)
// assume got->size == 0 too // assume got->size == 0 too
ld.Addaddrplus(ctxt, got, ld.Linklookup(ctxt, ".dynamic", 0), 0) ld.Addaddrplus(ctxt, got, ctxt.Syms.Lookup(".dynamic", 0), 0)
ld.Adduint64(ctxt, got, 0) ld.Adduint64(ctxt, got, 0)
ld.Adduint64(ctxt, got, 0) ld.Adduint64(ctxt, got, 0)
...@@ -561,9 +561,9 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -561,9 +561,9 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) {
ld.Adddynsym(ctxt, s) ld.Adddynsym(ctxt, s)
if ld.Iself { if ld.Iself {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
got := ld.Linklookup(ctxt, ".got.plt", 0) got := ctxt.Syms.Lookup(".got.plt", 0)
rela := ld.Linklookup(ctxt, ".rela.plt", 0) rela := ctxt.Syms.Lookup(".rela.plt", 0)
if plt.Size == 0 { if plt.Size == 0 {
elfsetupplt(ctxt) elfsetupplt(ctxt)
} }
...@@ -606,16 +606,16 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -606,16 +606,16 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) {
// has details about what we're avoiding. // has details about what we're avoiding.
addgotsym(ctxt, s) addgotsym(ctxt, s)
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
ld.Adduint32(ctxt, ld.Linklookup(ctxt, ".linkedit.plt", 0), uint32(s.Dynid)) ld.Adduint32(ctxt, ctxt.Syms.Lookup(".linkedit.plt", 0), uint32(s.Dynid))
// jmpq *got+size(IP) // jmpq *got+size(IP)
s.Plt = int32(plt.Size) s.Plt = int32(plt.Size)
ld.Adduint8(ctxt, plt, 0xff) ld.Adduint8(ctxt, plt, 0xff)
ld.Adduint8(ctxt, plt, 0x25) ld.Adduint8(ctxt, plt, 0x25)
ld.Addpcrelplus(ctxt, plt, ld.Linklookup(ctxt, ".got", 0), int64(s.Got)) ld.Addpcrelplus(ctxt, plt, ctxt.Syms.Lookup(".got", 0), int64(s.Got))
} else { } else {
ld.Errorf(s, "addpltsym: unsupported binary format") ld.Errorf(s, "addpltsym: unsupported binary format")
} }
...@@ -627,17 +627,17 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -627,17 +627,17 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) {
} }
ld.Adddynsym(ctxt, s) ld.Adddynsym(ctxt, s)
got := ld.Linklookup(ctxt, ".got", 0) got := ctxt.Syms.Lookup(".got", 0)
s.Got = int32(got.Size) s.Got = int32(got.Size)
ld.Adduint64(ctxt, got, 0) ld.Adduint64(ctxt, got, 0)
if ld.Iself { if ld.Iself {
rela := ld.Linklookup(ctxt, ".rela", 0) rela := ctxt.Syms.Lookup(".rela", 0)
ld.Addaddrplus(ctxt, rela, got, int64(s.Got)) ld.Addaddrplus(ctxt, rela, got, int64(s.Got))
ld.Adduint64(ctxt, rela, ld.ELF64_R_INFO(uint32(s.Dynid), ld.R_X86_64_GLOB_DAT)) ld.Adduint64(ctxt, rela, ld.ELF64_R_INFO(uint32(s.Dynid), ld.R_X86_64_GLOB_DAT))
ld.Adduint64(ctxt, rela, 0) ld.Adduint64(ctxt, rela, 0)
} else if ld.Headtype == obj.Hdarwin { } else if ld.Headtype == obj.Hdarwin {
ld.Adduint32(ctxt, ld.Linklookup(ctxt, ".linkedit.got", 0), uint32(s.Dynid)) ld.Adduint32(ctxt, ctxt.Syms.Lookup(".linkedit.got", 0), uint32(s.Dynid))
} else { } else {
ld.Errorf(s, "addgotsym: unsupported binary format") ld.Errorf(s, "addgotsym: unsupported binary format")
} }
...@@ -775,7 +775,7 @@ func asmb(ctxt *ld.Link) { ...@@ -775,7 +775,7 @@ func asmb(ctxt *ld.Link) {
ld.Asmplan9sym(ctxt) ld.Asmplan9sym(ctxt)
ld.Cflush() ld.Cflush()
sym := ld.Linklookup(ctxt, "pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { for i := 0; int32(i) < ld.Lcsize; i++ {
......
...@@ -62,14 +62,14 @@ func gentext(ctxt *ld.Link) { ...@@ -62,14 +62,14 @@ func gentext(ctxt *ld.Link) {
if !ctxt.DynlinkingGo() { if !ctxt.DynlinkingGo() {
return return
} }
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0) addmoduledata := ctxt.Syms.Lookup("runtime.addmoduledata", 0)
if addmoduledata.Type == obj.STEXT && ld.Buildmode != ld.BuildmodePlugin { if addmoduledata.Type == obj.STEXT && ld.Buildmode != ld.BuildmodePlugin {
// we're linking a module containing the runtime -> no need for // we're linking a module containing the runtime -> no need for
// an init function // an init function
return return
} }
addmoduledata.Attr |= ld.AttrReachable addmoduledata.Attr |= ld.AttrReachable
initfunc := ld.Linklookup(ctxt, "go.link.addmoduledata", 0) initfunc := ctxt.Syms.Lookup("go.link.addmoduledata", 0)
initfunc.Type = obj.STEXT initfunc.Type = obj.STEXT
initfunc.Attr |= ld.AttrLocal initfunc.Attr |= ld.AttrLocal
initfunc.Attr |= ld.AttrReachable initfunc.Attr |= ld.AttrReachable
...@@ -83,7 +83,7 @@ func gentext(ctxt *ld.Link) { ...@@ -83,7 +83,7 @@ func gentext(ctxt *ld.Link) {
rel := ld.Addrel(initfunc) rel := ld.Addrel(initfunc)
rel.Off = 8 rel.Off = 8
rel.Siz = 4 rel.Siz = 4
rel.Sym = ld.Linklookup(ctxt, "runtime.addmoduledata", 0) rel.Sym = ctxt.Syms.Lookup("runtime.addmoduledata", 0)
rel.Type = obj.R_CALLARM rel.Type = obj.R_CALLARM
rel.Add = 0xeafffffe // vomit rel.Add = 0xeafffffe // vomit
...@@ -99,7 +99,7 @@ func gentext(ctxt *ld.Link) { ...@@ -99,7 +99,7 @@ func gentext(ctxt *ld.Link) {
if ld.Buildmode == ld.BuildmodePlugin { if ld.Buildmode == ld.BuildmodePlugin {
ctxt.Textp = append(ctxt.Textp, addmoduledata) ctxt.Textp = append(ctxt.Textp, addmoduledata)
} }
initarray_entry := ld.Linklookup(ctxt, "go.link.addmoduledatainit", 0) initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0)
initarray_entry.Attr |= ld.AttrReachable initarray_entry.Attr |= ld.AttrReachable
initarray_entry.Attr |= ld.AttrLocal initarray_entry.Attr |= ld.AttrLocal
initarray_entry.Type = obj.SINITARR initarray_entry.Type = obj.SINITARR
...@@ -128,7 +128,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -128,7 +128,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
if targ.Type == obj.SDYNIMPORT { if targ.Type == obj.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(braddoff(int32(r.Add), targ.Plt/4)) r.Add = int64(braddoff(int32(r.Add), targ.Plt/4))
} }
...@@ -158,7 +158,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -158,7 +158,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
} }
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += int64(targ.Got) + 4 r.Add += int64(targ.Got) + 4
return true return true
...@@ -170,7 +170,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -170,7 +170,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
case 256 + ld.R_ARM_GOTPC: // R_ARM_BASE_PREL case 256 + ld.R_ARM_GOTPC: // R_ARM_BASE_PREL
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += 4 r.Add += 4
return true return true
...@@ -178,7 +178,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -178,7 +178,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
r.Type = obj.R_CALLARM r.Type = obj.R_CALLARM
if targ.Type == obj.SDYNIMPORT { if targ.Type == obj.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(braddoff(int32(r.Add), targ.Plt/4)) r.Add = int64(braddoff(int32(r.Add), targ.Plt/4))
} }
...@@ -212,7 +212,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -212,7 +212,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
r.Type = obj.R_CALLARM r.Type = obj.R_CALLARM
if targ.Type == obj.SDYNIMPORT { if targ.Type == obj.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(braddoff(int32(r.Add), targ.Plt/4)) r.Add = int64(braddoff(int32(r.Add), targ.Plt/4))
} }
...@@ -227,7 +227,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -227,7 +227,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
switch r.Type { switch r.Type {
case obj.R_CALLARM: case obj.R_CALLARM:
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(targ.Plt) r.Add = int64(targ.Plt)
return true return true
...@@ -237,7 +237,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -237,7 +237,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
} }
if ld.Iself { if ld.Iself {
ld.Adddynsym(ctxt, targ) ld.Adddynsym(ctxt, targ)
rel := ld.Linklookup(ctxt, ".rel", 0) rel := ctxt.Syms.Lookup(".rel", 0)
ld.Addaddrplus(ctxt, rel, s, int64(r.Off)) ld.Addaddrplus(ctxt, rel, s, int64(r.Off))
ld.Adduint32(ctxt, rel, ld.ELF32_R_INFO(uint32(targ.Dynid), ld.R_ARM_GLOB_DAT)) // we need a nil + A dynamic reloc ld.Adduint32(ctxt, rel, ld.ELF32_R_INFO(uint32(targ.Dynid), ld.R_ARM_GLOB_DAT)) // we need a nil + A dynamic reloc
r.Type = obj.R_CONST // write r->add during relocsym r.Type = obj.R_CONST // write r->add during relocsym
...@@ -300,8 +300,8 @@ func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int { ...@@ -300,8 +300,8 @@ func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
} }
func elfsetupplt(ctxt *ld.Link) { func elfsetupplt(ctxt *ld.Link) {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
got := ld.Linklookup(ctxt, ".got.plt", 0) got := ctxt.Syms.Lookup(".got.plt", 0)
if plt.Size == 0 { if plt.Size == 0 {
// str lr, [sp, #-4]! // str lr, [sp, #-4]!
ld.Adduint32(ctxt, plt, 0xe52de004) ld.Adduint32(ctxt, plt, 0xe52de004)
...@@ -457,25 +457,25 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int { ...@@ -457,25 +457,25 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
return 0 return 0
case obj.R_GOTOFF: case obj.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ld.Linklookup(ctxt, ".got", 0)) *val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
return 0 return 0
// The following three arch specific relocations are only for generation of // The following three arch specific relocations are only for generation of
// Linux/ARM ELF's PLT entry (3 assembler instruction) // Linux/ARM ELF's PLT entry (3 assembler instruction)
case obj.R_PLT0: // add ip, pc, #0xXX00000 case obj.R_PLT0: // add ip, pc, #0xXX00000
if ld.Symaddr(ld.Linklookup(ctxt, ".got.plt", 0)) < ld.Symaddr(ld.Linklookup(ctxt, ".plt", 0)) { if ld.Symaddr(ctxt.Syms.Lookup(".got.plt", 0)) < ld.Symaddr(ctxt.Syms.Lookup(".plt", 0)) {
ld.Errorf(s, ".got.plt should be placed after .plt section.") ld.Errorf(s, ".got.plt should be placed after .plt section.")
} }
*val = 0xe28fc600 + (0xff & (int64(uint32(ld.Symaddr(r.Sym)-(ld.Symaddr(ld.Linklookup(ctxt, ".plt", 0))+int64(r.Off))+r.Add)) >> 20)) *val = 0xe28fc600 + (0xff & (int64(uint32(ld.Symaddr(r.Sym)-(ld.Symaddr(ctxt.Syms.Lookup(".plt", 0))+int64(r.Off))+r.Add)) >> 20))
return 0 return 0
case obj.R_PLT1: // add ip, ip, #0xYY000 case obj.R_PLT1: // add ip, ip, #0xYY000
*val = 0xe28cca00 + (0xff & (int64(uint32(ld.Symaddr(r.Sym)-(ld.Symaddr(ld.Linklookup(ctxt, ".plt", 0))+int64(r.Off))+r.Add+4)) >> 12)) *val = 0xe28cca00 + (0xff & (int64(uint32(ld.Symaddr(r.Sym)-(ld.Symaddr(ctxt.Syms.Lookup(".plt", 0))+int64(r.Off))+r.Add+4)) >> 12))
return 0 return 0
case obj.R_PLT2: // ldr pc, [ip, #0xZZZ]! case obj.R_PLT2: // ldr pc, [ip, #0xZZZ]!
*val = 0xe5bcf000 + (0xfff & int64(uint32(ld.Symaddr(r.Sym)-(ld.Symaddr(ld.Linklookup(ctxt, ".plt", 0))+int64(r.Off))+r.Add+8))) *val = 0xe5bcf000 + (0xfff & int64(uint32(ld.Symaddr(r.Sym)-(ld.Symaddr(ctxt.Syms.Lookup(".plt", 0))+int64(r.Off))+r.Add+8)))
return 0 return 0
...@@ -516,9 +516,9 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -516,9 +516,9 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) {
ld.Adddynsym(ctxt, s) ld.Adddynsym(ctxt, s)
if ld.Iself { if ld.Iself {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
got := ld.Linklookup(ctxt, ".got.plt", 0) got := ctxt.Syms.Lookup(".got.plt", 0)
rel := ld.Linklookup(ctxt, ".rel.plt", 0) rel := ctxt.Syms.Lookup(".rel.plt", 0)
if plt.Size == 0 { if plt.Size == 0 {
elfsetupplt(ctxt) elfsetupplt(ctxt)
} }
...@@ -552,7 +552,7 @@ func addgotsyminternal(ctxt *ld.Link, s *ld.Symbol) { ...@@ -552,7 +552,7 @@ func addgotsyminternal(ctxt *ld.Link, s *ld.Symbol) {
return return
} }
got := ld.Linklookup(ctxt, ".got", 0) got := ctxt.Syms.Lookup(".got", 0)
s.Got = int32(got.Size) s.Got = int32(got.Size)
ld.Addaddrplus(ctxt, got, s, 0) ld.Addaddrplus(ctxt, got, s, 0)
...@@ -569,12 +569,12 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -569,12 +569,12 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) {
} }
ld.Adddynsym(ctxt, s) ld.Adddynsym(ctxt, s)
got := ld.Linklookup(ctxt, ".got", 0) got := ctxt.Syms.Lookup(".got", 0)
s.Got = int32(got.Size) s.Got = int32(got.Size)
ld.Adduint32(ctxt, got, 0) ld.Adduint32(ctxt, got, 0)
if ld.Iself { if ld.Iself {
rel := ld.Linklookup(ctxt, ".rel", 0) rel := ctxt.Syms.Lookup(".rel", 0)
ld.Addaddrplus(ctxt, rel, got, int64(s.Got)) ld.Addaddrplus(ctxt, rel, got, int64(s.Got))
ld.Adduint32(ctxt, rel, ld.ELF32_R_INFO(uint32(s.Dynid), ld.R_ARM_GLOB_DAT)) ld.Adduint32(ctxt, rel, ld.ELF32_R_INFO(uint32(s.Dynid), ld.R_ARM_GLOB_DAT))
} else { } else {
...@@ -673,7 +673,7 @@ func asmb(ctxt *ld.Link) { ...@@ -673,7 +673,7 @@ func asmb(ctxt *ld.Link) {
ld.Asmplan9sym(ctxt) ld.Asmplan9sym(ctxt)
ld.Cflush() ld.Cflush()
sym := ld.Linklookup(ctxt, "pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { for i := 0; int32(i) < ld.Lcsize; i++ {
......
...@@ -42,14 +42,14 @@ func gentext(ctxt *ld.Link) { ...@@ -42,14 +42,14 @@ func gentext(ctxt *ld.Link) {
if !ctxt.DynlinkingGo() { if !ctxt.DynlinkingGo() {
return return
} }
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0) addmoduledata := ctxt.Syms.Lookup("runtime.addmoduledata", 0)
if addmoduledata.Type == obj.STEXT { if addmoduledata.Type == obj.STEXT {
// we're linking a module containing the runtime -> no need for // we're linking a module containing the runtime -> no need for
// an init function // an init function
return return
} }
addmoduledata.Attr |= ld.AttrReachable addmoduledata.Attr |= ld.AttrReachable
initfunc := ld.Linklookup(ctxt, "go.link.addmoduledata", 0) initfunc := ctxt.Syms.Lookup("go.link.addmoduledata", 0)
initfunc.Type = obj.STEXT initfunc.Type = obj.STEXT
initfunc.Attr |= ld.AttrLocal initfunc.Attr |= ld.AttrLocal
initfunc.Attr |= ld.AttrReachable initfunc.Attr |= ld.AttrReachable
...@@ -75,11 +75,11 @@ func gentext(ctxt *ld.Link) { ...@@ -75,11 +75,11 @@ func gentext(ctxt *ld.Link) {
rel = ld.Addrel(initfunc) rel = ld.Addrel(initfunc)
rel.Off = 8 rel.Off = 8
rel.Siz = 4 rel.Siz = 4
rel.Sym = ld.Linklookup(ctxt, "runtime.addmoduledata", 0) rel.Sym = ctxt.Syms.Lookup("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
ctxt.Textp = append(ctxt.Textp, initfunc) ctxt.Textp = append(ctxt.Textp, initfunc)
initarray_entry := ld.Linklookup(ctxt, "go.link.addmoduledatainit", 0) initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0)
initarray_entry.Attr |= ld.AttrReachable initarray_entry.Attr |= ld.AttrReachable
initarray_entry.Attr |= ld.AttrLocal initarray_entry.Attr |= ld.AttrLocal
initarray_entry.Type = obj.SINITARR initarray_entry.Type = obj.SINITARR
...@@ -330,7 +330,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int { ...@@ -330,7 +330,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
return 0 return 0
case obj.R_GOTOFF: case obj.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ld.Linklookup(ctxt, ".got", 0)) *val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
return 0 return 0
case obj.R_ADDRARM64: case obj.R_ADDRARM64:
...@@ -482,7 +482,7 @@ func asmb(ctxt *ld.Link) { ...@@ -482,7 +482,7 @@ func asmb(ctxt *ld.Link) {
ld.Asmplan9sym(ctxt) ld.Asmplan9sym(ctxt)
ld.Cflush() ld.Cflush()
sym := ld.Linklookup(ctxt, "pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { for i := 0; int32(i) < ld.Lcsize; i++ {
......
This diff is collapsed.
...@@ -59,8 +59,8 @@ func deadcode(ctxt *Link) { ...@@ -59,8 +59,8 @@ func deadcode(ctxt *Link) {
d.init() d.init()
d.flood() d.flood()
callSym := Linkrlookup(ctxt, "reflect.Value.Call", 0) callSym := ctxt.Syms.ROLookup("reflect.Value.Call", 0)
methSym := Linkrlookup(ctxt, "reflect.Value.Method", 0) methSym := ctxt.Syms.ROLookup("reflect.Value.Method", 0)
reflectSeen := false reflectSeen := false
if ctxt.DynlinkingGo() { if ctxt.DynlinkingGo() {
...@@ -249,7 +249,7 @@ func (d *deadcodepass) init() { ...@@ -249,7 +249,7 @@ func (d *deadcodepass) init() {
// We don't keep the go.plugin.exports symbol, // We don't keep the go.plugin.exports symbol,
// but we do keep the symbols it refers to. // but we do keep the symbols it refers to.
exports := Linkrlookup(d.ctxt, "go.plugin.exports", 0) exports := d.ctxt.Syms.ROLookup("go.plugin.exports", 0)
for _, r := range exports.R { for _, r := range exports.R {
d.mark(r.Sym, nil) d.mark(r.Sym, nil)
} }
...@@ -263,7 +263,7 @@ func (d *deadcodepass) init() { ...@@ -263,7 +263,7 @@ func (d *deadcodepass) init() {
} }
for _, name := range names { for _, name := range names {
d.mark(Linkrlookup(d.ctxt, name, 0), nil) d.mark(d.ctxt.Syms.ROLookup(name, 0), nil)
} }
} }
......
...@@ -82,7 +82,7 @@ var gdbscript string ...@@ -82,7 +82,7 @@ var gdbscript string
var dwarfp []*Symbol var dwarfp []*Symbol
func writeabbrev(ctxt *Link, syms []*Symbol) []*Symbol { func writeabbrev(ctxt *Link, syms []*Symbol) []*Symbol {
s := Linklookup(ctxt, ".debug_abbrev", 0) s := ctxt.Syms.Lookup(".debug_abbrev", 0)
s.Type = obj.SDWARFSECT s.Type = obj.SDWARFSECT
abbrevsym = s abbrevsym = s
Addbytes(ctxt, s, dwarf.GetAbbrev()) Addbytes(ctxt, s, dwarf.GetAbbrev())
...@@ -146,7 +146,7 @@ func newdie(ctxt *Link, parent *dwarf.DWDie, abbrev int, name string, version in ...@@ -146,7 +146,7 @@ func newdie(ctxt *Link, parent *dwarf.DWDie, abbrev int, name string, version in
if name != "" && (abbrev <= dwarf.DW_ABRV_VARIABLE || abbrev >= dwarf.DW_ABRV_NULLTYPE) { if name != "" && (abbrev <= dwarf.DW_ABRV_VARIABLE || abbrev >= dwarf.DW_ABRV_NULLTYPE) {
if abbrev != dwarf.DW_ABRV_VARIABLE || version == 0 { if abbrev != dwarf.DW_ABRV_VARIABLE || version == 0 {
sym := Linklookup(ctxt, dwarf.InfoPrefix+name, version) sym := ctxt.Syms.Lookup(dwarf.InfoPrefix+name, version)
sym.Attr |= AttrHidden sym.Attr |= AttrHidden
sym.Type = obj.SDWARFINFO sym.Type = obj.SDWARFINFO
die.Sym = sym die.Sym = sym
...@@ -173,7 +173,7 @@ func walktypedef(die *dwarf.DWDie) *dwarf.DWDie { ...@@ -173,7 +173,7 @@ func walktypedef(die *dwarf.DWDie) *dwarf.DWDie {
} }
func walksymtypedef(ctxt *Link, s *Symbol) *Symbol { func walksymtypedef(ctxt *Link, s *Symbol) *Symbol {
if t := Linkrlookup(ctxt, s.Name+"..def", int(s.Version)); t != nil { if t := ctxt.Syms.ROLookup(s.Name+"..def", int(s.Version)); t != nil {
return t return t
} }
return s return s
...@@ -200,7 +200,7 @@ var prefixBuf = []byte(dwarf.InfoPrefix) ...@@ -200,7 +200,7 @@ var prefixBuf = []byte(dwarf.InfoPrefix)
func find(ctxt *Link, name string) *Symbol { func find(ctxt *Link, name string) *Symbol {
n := append(prefixBuf, name...) n := append(prefixBuf, name...)
// The string allocation below is optimized away because it is only used in a map lookup. // The string allocation below is optimized away because it is only used in a map lookup.
s := Linkrlookup(ctxt, string(n), 0) s := ctxt.Syms.ROLookup(string(n), 0)
prefixBuf = n[:len(dwarf.InfoPrefix)] prefixBuf = n[:len(dwarf.InfoPrefix)]
if s != nil && s.Type == obj.SDWARFINFO { if s != nil && s.Type == obj.SDWARFINFO {
return s return s
...@@ -312,7 +312,7 @@ func newabslocexprattr(die *dwarf.DWDie, addr int64, sym *Symbol) { ...@@ -312,7 +312,7 @@ func newabslocexprattr(die *dwarf.DWDie, addr int64, sym *Symbol) {
// Lookup predefined types // Lookup predefined types
func lookupOrDiag(ctxt *Link, n string) *Symbol { func lookupOrDiag(ctxt *Link, n string) *Symbol {
s := Linkrlookup(ctxt, n, 0) s := ctxt.Syms.ROLookup(n, 0)
if s == nil || s.Size == 0 { if s == nil || s.Size == 0 {
Exitf("dwarf: missing type: %s", n) Exitf("dwarf: missing type: %s", n)
} }
...@@ -338,7 +338,7 @@ func dotypedef(ctxt *Link, parent *dwarf.DWDie, name string, def *dwarf.DWDie) { ...@@ -338,7 +338,7 @@ func dotypedef(ctxt *Link, parent *dwarf.DWDie, name string, def *dwarf.DWDie) {
Errorf(nil, "dwarf: bad def in dotypedef") Errorf(nil, "dwarf: bad def in dotypedef")
} }
sym := Linklookup(ctxt, dtolsym(def.Sym).Name+"..def", 0) sym := ctxt.Syms.Lookup(dtolsym(def.Sym).Name+"..def", 0)
sym.Attr |= AttrHidden sym.Attr |= AttrHidden
sym.Type = obj.SDWARFINFO sym.Type = obj.SDWARFINFO
def.Sym = sym def.Sym = sym
...@@ -658,7 +658,7 @@ const ( ...@@ -658,7 +658,7 @@ const (
func mkinternaltype(ctxt *Link, abbrev int, typename, keyname, valname string, f func(*dwarf.DWDie)) *Symbol { func mkinternaltype(ctxt *Link, abbrev int, typename, keyname, valname string, f func(*dwarf.DWDie)) *Symbol {
name := mkinternaltypename(typename, keyname, valname) name := mkinternaltypename(typename, keyname, valname)
symname := dwarf.InfoPrefix + name symname := dwarf.InfoPrefix + name
s := Linkrlookup(ctxt, symname, 0) s := ctxt.Syms.ROLookup(symname, 0)
if s != nil && s.Type == obj.SDWARFINFO { if s != nil && s.Type == obj.SDWARFINFO {
return s return s
} }
...@@ -921,7 +921,7 @@ func getCompilationDir() string { ...@@ -921,7 +921,7 @@ func getCompilationDir() string {
func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) { func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) {
var dwarfctxt dwarf.Context = dwctxt{ctxt} var dwarfctxt dwarf.Context = dwctxt{ctxt}
if linesec == nil { if linesec == nil {
linesec = Linklookup(ctxt, ".debug_line", 0) linesec = ctxt.Syms.Lookup(".debug_line", 0)
} }
linesec.Type = obj.SDWARFSECT linesec.Type = obj.SDWARFSECT
linesec.R = linesec.R[:0] linesec.R = linesec.R[:0]
...@@ -1004,7 +1004,7 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) { ...@@ -1004,7 +1004,7 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) {
epc = s.Value + s.Size epc = s.Value + s.Size
epcs = s epcs = s
dsym := Linklookup(ctxt, dwarf.InfoPrefix+s.Name, int(s.Version)) dsym := ctxt.Syms.Lookup(dwarf.InfoPrefix+s.Name, int(s.Version))
dsym.Attr |= AttrHidden dsym.Attr |= AttrHidden
dsym.Type = obj.SDWARFINFO dsym.Type = obj.SDWARFINFO
for _, r := range dsym.R { for _, r := range dsym.R {
...@@ -1014,7 +1014,7 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) { ...@@ -1014,7 +1014,7 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) {
continue continue
} }
n := nameFromDIESym(r.Sym) n := nameFromDIESym(r.Sym)
defgotype(ctxt, Linklookup(ctxt, "type."+n, 0)) defgotype(ctxt, ctxt.Syms.Lookup("type."+n, 0))
} }
} }
funcs = append(funcs, dsym) funcs = append(funcs, dsym)
...@@ -1101,7 +1101,7 @@ func appendPCDeltaCFA(b []byte, deltapc, cfa int64) []byte { ...@@ -1101,7 +1101,7 @@ func appendPCDeltaCFA(b []byte, deltapc, cfa int64) []byte {
func writeframes(ctxt *Link, syms []*Symbol) []*Symbol { func writeframes(ctxt *Link, syms []*Symbol) []*Symbol {
var dwarfctxt dwarf.Context = dwctxt{ctxt} var dwarfctxt dwarf.Context = dwctxt{ctxt}
if framesec == nil { if framesec == nil {
framesec = Linklookup(ctxt, ".debug_frame", 0) framesec = ctxt.Syms.Lookup(".debug_frame", 0)
} }
framesec.Type = obj.SDWARFSECT framesec.Type = obj.SDWARFSECT
framesec.R = framesec.R[:0] framesec.R = framesec.R[:0]
...@@ -1222,7 +1222,7 @@ const ( ...@@ -1222,7 +1222,7 @@ const (
func writeinfo(ctxt *Link, syms []*Symbol, funcs []*Symbol) []*Symbol { func writeinfo(ctxt *Link, syms []*Symbol, funcs []*Symbol) []*Symbol {
if infosec == nil { if infosec == nil {
infosec = Linklookup(ctxt, ".debug_info", 0) infosec = ctxt.Syms.Lookup(".debug_info", 0)
} }
infosec.R = infosec.R[:0] infosec.R = infosec.R[:0]
infosec.Type = obj.SDWARFINFO infosec.Type = obj.SDWARFINFO
...@@ -1230,7 +1230,7 @@ func writeinfo(ctxt *Link, syms []*Symbol, funcs []*Symbol) []*Symbol { ...@@ -1230,7 +1230,7 @@ func writeinfo(ctxt *Link, syms []*Symbol, funcs []*Symbol) []*Symbol {
syms = append(syms, infosec) syms = append(syms, infosec)
if arangessec == nil { if arangessec == nil {
arangessec = Linklookup(ctxt, ".dwarfaranges", 0) arangessec = ctxt.Syms.Lookup(".dwarfaranges", 0)
} }
arangessec.R = arangessec.R[:0] arangessec.R = arangessec.R[:0]
...@@ -1290,7 +1290,7 @@ func ispubtype(die *dwarf.DWDie) bool { ...@@ -1290,7 +1290,7 @@ func ispubtype(die *dwarf.DWDie) bool {
} }
func writepub(ctxt *Link, sname string, ispub func(*dwarf.DWDie) bool, syms []*Symbol) []*Symbol { func writepub(ctxt *Link, sname string, ispub func(*dwarf.DWDie) bool, syms []*Symbol) []*Symbol {
s := Linklookup(ctxt, sname, 0) s := ctxt.Syms.Lookup(sname, 0)
s.Type = obj.SDWARFSECT s.Type = obj.SDWARFSECT
syms = append(syms, s) syms = append(syms, s)
...@@ -1330,7 +1330,7 @@ func writepub(ctxt *Link, sname string, ispub func(*dwarf.DWDie) bool, syms []*S ...@@ -1330,7 +1330,7 @@ func writepub(ctxt *Link, sname string, ispub func(*dwarf.DWDie) bool, syms []*S
* because we need die->offs of dwarf.DW_globals. * because we need die->offs of dwarf.DW_globals.
*/ */
func writearanges(ctxt *Link, syms []*Symbol) []*Symbol { func writearanges(ctxt *Link, syms []*Symbol) []*Symbol {
s := Linklookup(ctxt, ".debug_aranges", 0) s := ctxt.Syms.Lookup(".debug_aranges", 0)
s.Type = obj.SDWARFSECT s.Type = obj.SDWARFSECT
// The first tuple is aligned to a multiple of the size of a single tuple // The first tuple is aligned to a multiple of the size of a single tuple
// (twice the size of an address) // (twice the size of an address)
...@@ -1374,7 +1374,7 @@ func writearanges(ctxt *Link, syms []*Symbol) []*Symbol { ...@@ -1374,7 +1374,7 @@ func writearanges(ctxt *Link, syms []*Symbol) []*Symbol {
func writegdbscript(ctxt *Link, syms []*Symbol) []*Symbol { func writegdbscript(ctxt *Link, syms []*Symbol) []*Symbol {
if gdbscript != "" { if gdbscript != "" {
s := Linklookup(ctxt, ".debug_gdb_scripts", 0) s := ctxt.Syms.Lookup(".debug_gdb_scripts", 0)
s.Type = obj.SDWARFSECT s.Type = obj.SDWARFSECT
syms = append(syms, s) syms = append(syms, s)
Adduint8(ctxt, s, 1) // magic 1 byte? Adduint8(ctxt, s, 1) // magic 1 byte?
...@@ -1512,13 +1512,13 @@ func dwarfaddelfsectionsyms(ctxt *Link) { ...@@ -1512,13 +1512,13 @@ func dwarfaddelfsectionsyms(ctxt *Link) {
if Linkmode != LinkExternal { if Linkmode != LinkExternal {
return return
} }
sym := Linklookup(ctxt, ".debug_info", 0) sym := ctxt.Syms.Lookup(".debug_info", 0)
putelfsectionsym(sym, sym.Sect.Elfsect.shnum) putelfsectionsym(sym, sym.Sect.Elfsect.shnum)
sym = Linklookup(ctxt, ".debug_abbrev", 0) sym = ctxt.Syms.Lookup(".debug_abbrev", 0)
putelfsectionsym(sym, sym.Sect.Elfsect.shnum) putelfsectionsym(sym, sym.Sect.Elfsect.shnum)
sym = Linklookup(ctxt, ".debug_line", 0) sym = ctxt.Syms.Lookup(".debug_line", 0)
putelfsectionsym(sym, sym.Sect.Elfsect.shnum) putelfsectionsym(sym, sym.Sect.Elfsect.shnum)
sym = Linklookup(ctxt, ".debug_frame", 0) sym = ctxt.Syms.Lookup(".debug_frame", 0)
putelfsectionsym(sym, sym.Sect.Elfsect.shnum) putelfsectionsym(sym, sym.Sect.Elfsect.shnum)
} }
......
This diff is collapsed.
...@@ -187,7 +187,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) { ...@@ -187,7 +187,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) {
if i := strings.Index(remote, "#"); i >= 0 { if i := strings.Index(remote, "#"); i >= 0 {
remote, q = remote[:i], remote[i+1:] remote, q = remote[:i], remote[i+1:]
} }
s = Linklookup(ctxt, local, 0) s = ctxt.Syms.Lookup(local, 0)
if local != f[1] { if local != f[1] {
} }
if s.Type == 0 || s.Type == obj.SXREF || s.Type == obj.SHOSTOBJ { if s.Type == 0 || s.Type == obj.SXREF || s.Type == obj.SHOSTOBJ {
...@@ -208,7 +208,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) { ...@@ -208,7 +208,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) {
goto err goto err
} }
local = f[1] local = f[1]
s = Linklookup(ctxt, local, 0) s = ctxt.Syms.Lookup(local, 0)
s.Type = obj.SHOSTOBJ s.Type = obj.SHOSTOBJ
s.Size = 0 s.Size = 0
continue continue
...@@ -225,11 +225,11 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) { ...@@ -225,11 +225,11 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) {
remote = local remote = local
} }
local = expandpkg(local, pkg) local = expandpkg(local, pkg)
s = Linklookup(ctxt, local, 0) s = ctxt.Syms.Lookup(local, 0)
switch Buildmode { switch Buildmode {
case BuildmodeCShared, BuildmodeCArchive, BuildmodePlugin: case BuildmodeCShared, BuildmodeCArchive, BuildmodePlugin:
if s == Linklookup(ctxt, "main", 0) { if s == ctxt.Syms.Lookup("main", 0) {
continue continue
} }
} }
...@@ -305,11 +305,11 @@ func adddynlib(ctxt *Link, lib string) { ...@@ -305,11 +305,11 @@ func adddynlib(ctxt *Link, lib string) {
seenlib[lib] = true seenlib[lib] = true
if Iself { if Iself {
s := Linklookup(ctxt, ".dynstr", 0) s := ctxt.Syms.Lookup(".dynstr", 0)
if s.Size == 0 { if s.Size == 0 {
Addstring(ctxt, s, "") Addstring(ctxt, s, "")
} }
Elfwritedynent(ctxt, Linklookup(ctxt, ".dynamic", 0), DT_NEEDED, uint64(Addstring(ctxt, s, lib))) Elfwritedynent(ctxt, ctxt.Syms.Lookup(".dynamic", 0), DT_NEEDED, uint64(Addstring(ctxt, s, lib)))
} else { } else {
Errorf(nil, "adddynlib: unsupported binary format") Errorf(nil, "adddynlib: unsupported binary format")
} }
...@@ -355,7 +355,7 @@ func fieldtrack(ctxt *Link) { ...@@ -355,7 +355,7 @@ func fieldtrack(ctxt *Link) {
if *flagFieldTrack == "" { if *flagFieldTrack == "" {
return return
} }
s := Linklookup(ctxt, *flagFieldTrack, 0) s := ctxt.Syms.Lookup(*flagFieldTrack, 0)
if !s.Attr.Reachable() { if !s.Attr.Reachable() {
return return
} }
......
...@@ -702,7 +702,7 @@ func ldelf(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) { ...@@ -702,7 +702,7 @@ func ldelf(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
} }
name = fmt.Sprintf("%s(%s)", pkg, sect.name) name = fmt.Sprintf("%s(%s)", pkg, sect.name)
s = Linklookup(ctxt, name, ctxt.Syms.Version) s = ctxt.Syms.Lookup(name, ctxt.Syms.Version)
switch int(sect.flags) & (ElfSectFlagAlloc | ElfSectFlagWrite | ElfSectFlagExec) { switch int(sect.flags) & (ElfSectFlagAlloc | ElfSectFlagWrite | ElfSectFlagExec) {
default: default:
...@@ -1033,7 +1033,7 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int) (er ...@@ -1033,7 +1033,7 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int) (er
switch sym.bind { switch sym.bind {
case ElfSymBindGlobal: case ElfSymBindGlobal:
if needSym != 0 { if needSym != 0 {
s = Linklookup(ctxt, sym.name, 0) s = ctxt.Syms.Lookup(sym.name, 0)
// for global scoped hidden symbols we should insert it into // for global scoped hidden symbols we should insert it into
// symbol hash table, but mark them as hidden. // symbol hash table, but mark them as hidden.
...@@ -1059,7 +1059,7 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int) (er ...@@ -1059,7 +1059,7 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int) (er
// We need to be able to look this up, // We need to be able to look this up,
// so put it in the hash table. // so put it in the hash table.
if needSym != 0 { if needSym != 0 {
s = Linklookup(ctxt, sym.name, ctxt.Syms.Version) s = ctxt.Syms.Lookup(sym.name, ctxt.Syms.Version)
s.Type |= obj.SHIDDEN s.Type |= obj.SHIDDEN
} }
...@@ -1077,7 +1077,7 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int) (er ...@@ -1077,7 +1077,7 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int) (er
case ElfSymBindWeak: case ElfSymBindWeak:
if needSym != 0 { if needSym != 0 {
s = Linklookup(ctxt, sym.name, 0) s = ctxt.Syms.Lookup(sym.name, 0)
if sym.other == 2 { if sym.other == 2 {
s.Type |= obj.SHIDDEN s.Type |= obj.SHIDDEN
} }
......
...@@ -587,7 +587,7 @@ func ldmacho(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) { ...@@ -587,7 +587,7 @@ func ldmacho(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
continue continue
} }
name = fmt.Sprintf("%s(%s/%s)", pkg, sect.segname, sect.name) name = fmt.Sprintf("%s(%s/%s)", pkg, sect.segname, sect.name)
s = Linklookup(ctxt, name, ctxt.Syms.Version) s = ctxt.Syms.Lookup(name, ctxt.Syms.Version)
if s.Type != 0 { if s.Type != 0 {
err = fmt.Errorf("duplicate %s/%s", sect.segname, sect.name) err = fmt.Errorf("duplicate %s/%s", sect.segname, sect.name)
goto bad goto bad
...@@ -636,7 +636,7 @@ func ldmacho(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) { ...@@ -636,7 +636,7 @@ func ldmacho(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
if sym.type_&N_EXT == 0 { if sym.type_&N_EXT == 0 {
v = ctxt.Syms.Version v = ctxt.Syms.Version
} }
s = Linklookup(ctxt, name, v) s = ctxt.Syms.Lookup(name, v)
if sym.type_&N_EXT == 0 { if sym.type_&N_EXT == 0 {
s.Attr |= AttrDuplicateOK s.Attr |= AttrDuplicateOK
} }
......
...@@ -246,7 +246,7 @@ func ldpe(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) { ...@@ -246,7 +246,7 @@ func ldpe(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
} }
name = fmt.Sprintf("%s(%s)", pkg, sect.name) name = fmt.Sprintf("%s(%s)", pkg, sect.name)
s = Linklookup(ctxt, name, ctxt.Syms.Version) s = ctxt.Syms.Lookup(name, ctxt.Syms.Version)
switch sect.sh.Characteristics & (IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE) { switch sect.sh.Characteristics & (IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE) {
case IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ: //.rdata case IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ: //.rdata
...@@ -511,10 +511,10 @@ func readpesym(ctxt *Link, peobj *PeObj, i int, y **PeSym) (err error) { ...@@ -511,10 +511,10 @@ func readpesym(ctxt *Link, peobj *PeObj, i int, y **PeSym) (err error) {
case IMAGE_SYM_DTYPE_FUNCTION, IMAGE_SYM_DTYPE_NULL: case IMAGE_SYM_DTYPE_FUNCTION, IMAGE_SYM_DTYPE_NULL:
switch sym.sclass { switch sym.sclass {
case IMAGE_SYM_CLASS_EXTERNAL: //global case IMAGE_SYM_CLASS_EXTERNAL: //global
s = Linklookup(ctxt, name, 0) s = ctxt.Syms.Lookup(name, 0)
case IMAGE_SYM_CLASS_NULL, IMAGE_SYM_CLASS_STATIC, IMAGE_SYM_CLASS_LABEL: case IMAGE_SYM_CLASS_NULL, IMAGE_SYM_CLASS_STATIC, IMAGE_SYM_CLASS_LABEL:
s = Linklookup(ctxt, name, ctxt.Syms.Version) s = ctxt.Syms.Lookup(name, ctxt.Syms.Version)
s.Attr |= AttrDuplicateOK s.Attr |= AttrDuplicateOK
default: default:
......
...@@ -167,7 +167,7 @@ func (ctxt *Link) DynlinkingGo() bool { ...@@ -167,7 +167,7 @@ func (ctxt *Link) DynlinkingGo() bool {
if !ctxt.Loaded { if !ctxt.Loaded {
panic("DynlinkingGo called before all symbols loaded") panic("DynlinkingGo called before all symbols loaded")
} }
canUsePlugins := Linkrlookup(ctxt, "plugin.Open", 0) != nil canUsePlugins := ctxt.Syms.ROLookup("plugin.Open", 0) != nil
return Buildmode == BuildmodeShared || *FlagLinkshared || Buildmode == BuildmodePlugin || canUsePlugins return Buildmode == BuildmodeShared || *FlagLinkshared || Buildmode == BuildmodePlugin || canUsePlugins
} }
...@@ -391,11 +391,11 @@ func (ctxt *Link) findLibPath(libname string) string { ...@@ -391,11 +391,11 @@ func (ctxt *Link) findLibPath(libname string) string {
func (ctxt *Link) loadlib() { func (ctxt *Link) loadlib() {
switch Buildmode { switch Buildmode {
case BuildmodeCShared, BuildmodePlugin: case BuildmodeCShared, BuildmodePlugin:
s := Linklookup(ctxt, "runtime.islibrary", 0) s := ctxt.Syms.Lookup("runtime.islibrary", 0)
s.Attr |= AttrDuplicateOK s.Attr |= AttrDuplicateOK
Adduint8(ctxt, s, 1) Adduint8(ctxt, s, 1)
case BuildmodeCArchive: case BuildmodeCArchive:
s := Linklookup(ctxt, "runtime.isarchive", 0) s := ctxt.Syms.Lookup("runtime.isarchive", 0)
s.Attr |= AttrDuplicateOK s.Attr |= AttrDuplicateOK
Adduint8(ctxt, s, 1) Adduint8(ctxt, s, 1)
} }
...@@ -435,7 +435,7 @@ func (ctxt *Link) loadlib() { ...@@ -435,7 +435,7 @@ func (ctxt *Link) loadlib() {
determineLinkMode(ctxt) determineLinkMode(ctxt)
if Linkmode == LinkExternal && SysArch.Family == sys.PPC64 { if Linkmode == LinkExternal && SysArch.Family == sys.PPC64 {
toc := Linklookup(ctxt, ".TOC.", 0) toc := ctxt.Syms.Lookup(".TOC.", 0)
toc.Type = obj.SDYNIMPORT toc.Type = obj.SDYNIMPORT
} }
...@@ -476,7 +476,7 @@ func (ctxt *Link) loadlib() { ...@@ -476,7 +476,7 @@ func (ctxt *Link) loadlib() {
} }
} }
tlsg := Linklookup(ctxt, "runtime.tlsg", 0) tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
// runtime.tlsg is used for external linking on platforms that do not define // runtime.tlsg is used for external linking on platforms that do not define
// a variable to hold g in assembly (currently only intel). // a variable to hold g in assembly (currently only intel).
...@@ -491,10 +491,10 @@ func (ctxt *Link) loadlib() { ...@@ -491,10 +491,10 @@ func (ctxt *Link) loadlib() {
var moduledata *Symbol var moduledata *Symbol
if Buildmode == BuildmodePlugin { if Buildmode == BuildmodePlugin {
moduledata = Linklookup(ctxt, "local.pluginmoduledata", 0) moduledata = ctxt.Syms.Lookup("local.pluginmoduledata", 0)
moduledata.Attr |= AttrLocal moduledata.Attr |= AttrLocal
} else { } else {
moduledata = Linklookup(ctxt, "runtime.firstmoduledata", 0) moduledata = ctxt.Syms.Lookup("runtime.firstmoduledata", 0)
} }
if moduledata.Type != 0 && moduledata.Type != obj.SDYNIMPORT { if moduledata.Type != 0 && moduledata.Type != obj.SDYNIMPORT {
// If the module (toolchain-speak for "executable or shared // If the module (toolchain-speak for "executable or shared
...@@ -507,14 +507,14 @@ func (ctxt *Link) loadlib() { ...@@ -507,14 +507,14 @@ func (ctxt *Link) loadlib() {
// In addition, on ARM, the runtime depends on the linker // In addition, on ARM, the runtime depends on the linker
// recording the value of GOARM. // recording the value of GOARM.
if SysArch.Family == sys.ARM { if SysArch.Family == sys.ARM {
s := Linklookup(ctxt, "runtime.goarm", 0) s := ctxt.Syms.Lookup("runtime.goarm", 0)
s.Type = obj.SRODATA s.Type = obj.SRODATA
s.Size = 0 s.Size = 0
Adduint8(ctxt, s, uint8(obj.GOARM)) Adduint8(ctxt, s, uint8(obj.GOARM))
} }
if obj.Framepointer_enabled(obj.GOOS, obj.GOARCH) { if obj.Framepointer_enabled(obj.GOOS, obj.GOARCH) {
s := Linklookup(ctxt, "runtime.framepointer_enabled", 0) s := ctxt.Syms.Lookup("runtime.framepointer_enabled", 0)
s.Type = obj.SRODATA s.Type = obj.SRODATA
s.Size = 0 s.Size = 0
Adduint8(ctxt, s, 1) Adduint8(ctxt, s, 1)
...@@ -522,7 +522,7 @@ func (ctxt *Link) loadlib() { ...@@ -522,7 +522,7 @@ func (ctxt *Link) loadlib() {
} else { } else {
// If OTOH the module does not contain the runtime package, // If OTOH the module does not contain the runtime package,
// create a local symbol for the moduledata. // create a local symbol for the moduledata.
moduledata = Linklookup(ctxt, "local.moduledata", 0) moduledata = ctxt.Syms.Lookup("local.moduledata", 0)
moduledata.Attr |= AttrLocal moduledata.Attr |= AttrLocal
} }
// In all cases way we mark the moduledata as noptrdata to hide it from // In all cases way we mark the moduledata as noptrdata to hide it from
...@@ -610,7 +610,7 @@ func (ctxt *Link) loadlib() { ...@@ -610,7 +610,7 @@ func (ctxt *Link) loadlib() {
if SysArch == sys.Arch386 { if SysArch == sys.Arch386 {
if (Buildmode == BuildmodeCArchive && Iself) || Buildmode == BuildmodeCShared || Buildmode == BuildmodePIE || ctxt.DynlinkingGo() { if (Buildmode == BuildmodeCArchive && Iself) || Buildmode == BuildmodeCShared || Buildmode == BuildmodePIE || ctxt.DynlinkingGo() {
got := Linklookup(ctxt, "_GLOBAL_OFFSET_TABLE_", 0) got := ctxt.Syms.Lookup("_GLOBAL_OFFSET_TABLE_", 0)
got.Type = obj.SDYNIMPORT got.Type = obj.SDYNIMPORT
got.Attr |= AttrReachable got.Attr |= AttrReachable
} }
...@@ -1414,7 +1414,7 @@ func ldshlibsyms(ctxt *Link, shlib string) { ...@@ -1414,7 +1414,7 @@ func ldshlibsyms(ctxt *Link, shlib string) {
if elf.ST_TYPE(elfsym.Info) == elf.STT_NOTYPE || elf.ST_TYPE(elfsym.Info) == elf.STT_SECTION { if elf.ST_TYPE(elfsym.Info) == elf.STT_NOTYPE || elf.ST_TYPE(elfsym.Info) == elf.STT_SECTION {
continue continue
} }
lsym := Linklookup(ctxt, elfsym.Name, 0) lsym := ctxt.Syms.Lookup(elfsym.Name, 0)
// Because loadlib above loads all .a files before loading any shared // Because loadlib above loads all .a files before loading any shared
// libraries, any non-dynimport symbols we find that duplicate symbols // libraries, any non-dynimport symbols we find that duplicate symbols
// already loaded should be ignored (the symbols from the .a files // already loaded should be ignored (the symbols from the .a files
...@@ -1564,7 +1564,7 @@ func callsize(ctxt *Link) int { ...@@ -1564,7 +1564,7 @@ func callsize(ctxt *Link) int {
func (ctxt *Link) dostkcheck() { func (ctxt *Link) dostkcheck() {
var ch chain var ch chain
morestack = Linklookup(ctxt, "runtime.morestack", 0) morestack = ctxt.Syms.Lookup("runtime.morestack", 0)
// Every splitting function ensures that there are at least StackLimit // Every splitting function ensures that there are at least StackLimit
// bytes available below SP when the splitting prologue finishes. // bytes available below SP when the splitting prologue finishes.
...@@ -1808,11 +1808,11 @@ const ( ...@@ -1808,11 +1808,11 @@ const (
func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, *Symbol)) { func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, *Symbol)) {
// These symbols won't show up in the first loop below because we // These symbols won't show up in the first loop below because we
// skip STEXT symbols. Normal STEXT symbols are emitted by walking textp. // skip STEXT symbols. Normal STEXT symbols are emitted by walking textp.
s := Linklookup(ctxt, "runtime.text", 0) s := ctxt.Syms.Lookup("runtime.text", 0)
if s.Type == obj.STEXT { if s.Type == obj.STEXT {
put(ctxt, s, s.Name, TextSym, s.Value, nil) put(ctxt, s, s.Name, TextSym, s.Value, nil)
} }
s = Linklookup(ctxt, "runtime.etext", 0) s = ctxt.Syms.Lookup("runtime.etext", 0)
if s.Type == obj.STEXT { if s.Type == obj.STEXT {
put(ctxt, s, s.Name, TextSym, s.Value, nil) put(ctxt, s, s.Name, TextSym, s.Value, nil)
} }
...@@ -1942,7 +1942,7 @@ func Symaddr(s *Symbol) int64 { ...@@ -1942,7 +1942,7 @@ func Symaddr(s *Symbol) int64 {
} }
func (ctxt *Link) xdefine(p string, t obj.SymKind, v int64) { func (ctxt *Link) xdefine(p string, t obj.SymKind, v int64) {
s := Linklookup(ctxt, p, 0) s := ctxt.Syms.Lookup(p, 0)
s.Type = t s.Type = t
s.Value = v s.Value = v
s.Attr |= AttrReachable s.Attr |= AttrReachable
...@@ -1966,7 +1966,7 @@ func Entryvalue(ctxt *Link) int64 { ...@@ -1966,7 +1966,7 @@ func Entryvalue(ctxt *Link) int64 {
if a[0] >= '0' && a[0] <= '9' { if a[0] >= '0' && a[0] <= '9' {
return atolwhex(a) return atolwhex(a)
} }
s := Linklookup(ctxt, a, 0) s := ctxt.Syms.Lookup(a, 0)
if s.Type == 0 { if s.Type == 0 {
return *FlagTextAddr return *FlagTextAddr
} }
......
...@@ -300,32 +300,32 @@ func (ctxt *Link) domacho() { ...@@ -300,32 +300,32 @@ func (ctxt *Link) domacho() {
} }
// empirically, string table must begin with " \x00". // empirically, string table must begin with " \x00".
s := Linklookup(ctxt, ".machosymstr", 0) s := ctxt.Syms.Lookup(".machosymstr", 0)
s.Type = obj.SMACHOSYMSTR s.Type = obj.SMACHOSYMSTR
s.Attr |= AttrReachable s.Attr |= AttrReachable
Adduint8(ctxt, s, ' ') Adduint8(ctxt, s, ' ')
Adduint8(ctxt, s, '\x00') Adduint8(ctxt, s, '\x00')
s = Linklookup(ctxt, ".machosymtab", 0) s = ctxt.Syms.Lookup(".machosymtab", 0)
s.Type = obj.SMACHOSYMTAB s.Type = obj.SMACHOSYMTAB
s.Attr |= AttrReachable s.Attr |= AttrReachable
if Linkmode != LinkExternal { if Linkmode != LinkExternal {
s := Linklookup(ctxt, ".plt", 0) // will be __symbol_stub s := ctxt.Syms.Lookup(".plt", 0) // will be __symbol_stub
s.Type = obj.SMACHOPLT s.Type = obj.SMACHOPLT
s.Attr |= AttrReachable s.Attr |= AttrReachable
s = Linklookup(ctxt, ".got", 0) // will be __nl_symbol_ptr s = ctxt.Syms.Lookup(".got", 0) // will be __nl_symbol_ptr
s.Type = obj.SMACHOGOT s.Type = obj.SMACHOGOT
s.Attr |= AttrReachable s.Attr |= AttrReachable
s.Align = 4 s.Align = 4
s = Linklookup(ctxt, ".linkedit.plt", 0) // indirect table for .plt s = ctxt.Syms.Lookup(".linkedit.plt", 0) // indirect table for .plt
s.Type = obj.SMACHOINDIRECTPLT s.Type = obj.SMACHOINDIRECTPLT
s.Attr |= AttrReachable s.Attr |= AttrReachable
s = Linklookup(ctxt, ".linkedit.got", 0) // indirect table for .got s = ctxt.Syms.Lookup(".linkedit.got", 0) // indirect table for .got
s.Type = obj.SMACHOINDIRECTGOT s.Type = obj.SMACHOINDIRECTGOT
s.Attr |= AttrReachable s.Attr |= AttrReachable
} }
...@@ -400,7 +400,7 @@ func machoshbits(ctxt *Link, mseg *MachoSeg, sect *Section, segname string) { ...@@ -400,7 +400,7 @@ func machoshbits(ctxt *Link, mseg *MachoSeg, sect *Section, segname string) {
if sect.Name == ".got" { if sect.Name == ".got" {
msect.name = "__nl_symbol_ptr" msect.name = "__nl_symbol_ptr"
msect.flag = 6 /* section with nonlazy symbol pointers */ msect.flag = 6 /* section with nonlazy symbol pointers */
msect.res1 = uint32(Linklookup(ctxt, ".linkedit.plt", 0).Size / 4) /* offset into indirect symbol table */ msect.res1 = uint32(ctxt.Syms.Lookup(".linkedit.plt", 0).Size / 4) /* offset into indirect symbol table */
} }
if sect.Name == ".init_array" { if sect.Name == ".init_array" {
...@@ -541,10 +541,10 @@ func Asmbmacho(ctxt *Link) { ...@@ -541,10 +541,10 @@ func Asmbmacho(ctxt *Link) {
if !*FlagD { if !*FlagD {
// must match domacholink below // must match domacholink below
s1 := Linklookup(ctxt, ".machosymtab", 0) s1 := ctxt.Syms.Lookup(".machosymtab", 0)
s2 := Linklookup(ctxt, ".linkedit.plt", 0) s2 := ctxt.Syms.Lookup(".linkedit.plt", 0)
s3 := Linklookup(ctxt, ".linkedit.got", 0) s3 := ctxt.Syms.Lookup(".linkedit.got", 0)
s4 := Linklookup(ctxt, ".machosymstr", 0) s4 := ctxt.Syms.Lookup(".machosymstr", 0)
if Linkmode != LinkExternal { if Linkmode != LinkExternal {
ms := newMachoSeg("__LINKEDIT", 0) ms := newMachoSeg("__LINKEDIT", 0)
...@@ -685,8 +685,8 @@ func machosymorder(ctxt *Link) { ...@@ -685,8 +685,8 @@ func machosymorder(ctxt *Link) {
} }
func machosymtab(ctxt *Link) { func machosymtab(ctxt *Link) {
symtab := Linklookup(ctxt, ".machosymtab", 0) symtab := ctxt.Syms.Lookup(".machosymtab", 0)
symstr := Linklookup(ctxt, ".machosymstr", 0) symstr := ctxt.Syms.Lookup(".machosymstr", 0)
for i := 0; i < nsortsym; i++ { for i := 0; i < nsortsym; i++ {
s := sortsym[i] s := sortsym[i]
...@@ -750,10 +750,10 @@ func machodysymtab(ctxt *Link) { ...@@ -750,10 +750,10 @@ func machodysymtab(ctxt *Link) {
ml.data[11] = 0 /* nextrefsyms */ ml.data[11] = 0 /* nextrefsyms */
// must match domacholink below // must match domacholink below
s1 := Linklookup(ctxt, ".machosymtab", 0) s1 := ctxt.Syms.Lookup(".machosymtab", 0)
s2 := Linklookup(ctxt, ".linkedit.plt", 0) s2 := ctxt.Syms.Lookup(".linkedit.plt", 0)
s3 := Linklookup(ctxt, ".linkedit.got", 0) s3 := ctxt.Syms.Lookup(".linkedit.got", 0)
ml.data[12] = uint32(linkoff + s1.Size) /* indirectsymoff */ ml.data[12] = uint32(linkoff + s1.Size) /* indirectsymoff */
ml.data[13] = uint32((s2.Size + s3.Size) / 4) /* nindirectsyms */ ml.data[13] = uint32((s2.Size + s3.Size) / 4) /* nindirectsyms */
...@@ -767,11 +767,11 @@ func Domacholink(ctxt *Link) int64 { ...@@ -767,11 +767,11 @@ func Domacholink(ctxt *Link) int64 {
machosymtab(ctxt) machosymtab(ctxt)
// write data that will be linkedit section // write data that will be linkedit section
s1 := Linklookup(ctxt, ".machosymtab", 0) s1 := ctxt.Syms.Lookup(".machosymtab", 0)
s2 := Linklookup(ctxt, ".linkedit.plt", 0) s2 := ctxt.Syms.Lookup(".linkedit.plt", 0)
s3 := Linklookup(ctxt, ".linkedit.got", 0) s3 := ctxt.Syms.Lookup(".linkedit.got", 0)
s4 := Linklookup(ctxt, ".machosymstr", 0) s4 := ctxt.Syms.Lookup(".machosymstr", 0)
// Force the linkedit section to end on a 16-byte // Force the linkedit section to end on a 16-byte
// boundary. This allows pure (non-cgo) Go binaries // boundary. This allows pure (non-cgo) Go binaries
......
...@@ -454,7 +454,7 @@ func (r *objReader) readRef() { ...@@ -454,7 +454,7 @@ func (r *objReader) readRef() {
if v == 1 { if v == 1 {
v = r.ctxt.Syms.Version v = r.ctxt.Syms.Version
} }
s := Linklookup(r.ctxt, name, v) s := r.ctxt.Syms.Lookup(name, v)
r.refs = append(r.refs, s) r.refs = append(r.refs, s)
if s == nil || v != 0 { if s == nil || v != 0 {
......
...@@ -208,7 +208,7 @@ var pclntabLastFunc *Symbol ...@@ -208,7 +208,7 @@ var pclntabLastFunc *Symbol
func (ctxt *Link) pclntab() { func (ctxt *Link) pclntab() {
funcdataBytes := int64(0) funcdataBytes := int64(0)
ftab := Linklookup(ctxt, "runtime.pclntab", 0) ftab := ctxt.Syms.Lookup("runtime.pclntab", 0)
ftab.Type = obj.SPCLNTAB ftab.Type = obj.SPCLNTAB
ftab.Attr |= AttrReachable ftab.Attr |= AttrReachable
...@@ -393,7 +393,7 @@ const ( ...@@ -393,7 +393,7 @@ const (
// findfunctab generates a lookup table to quickly find the containing // findfunctab generates a lookup table to quickly find the containing
// function for a pc. See src/runtime/symtab.go:findfunc for details. // function for a pc. See src/runtime/symtab.go:findfunc for details.
func (ctxt *Link) findfunctab() { func (ctxt *Link) findfunctab() {
t := Linklookup(ctxt, "runtime.findfunctab", 0) t := ctxt.Syms.Lookup("runtime.findfunctab", 0)
t.Type = obj.SRODATA t.Type = obj.SRODATA
t.Attr |= AttrReachable t.Attr |= AttrReachable
t.Attr |= AttrLocal t.Attr |= AttrLocal
......
...@@ -527,7 +527,7 @@ func initdynimport(ctxt *Link) *Dll { ...@@ -527,7 +527,7 @@ func initdynimport(ctxt *Link) *Dll {
if SysArch.Family == sys.I386 && m.argsize >= 0 { if SysArch.Family == sys.I386 && m.argsize >= 0 {
dynName += fmt.Sprintf("@%d", m.argsize) dynName += fmt.Sprintf("@%d", m.argsize)
} }
dynSym := Linklookup(ctxt, dynName, 0) dynSym := ctxt.Syms.Lookup(dynName, 0)
dynSym.Attr |= AttrReachable dynSym.Attr |= AttrReachable
dynSym.Type = obj.SHOSTOBJ dynSym.Type = obj.SHOSTOBJ
r := Addrel(m.s) r := Addrel(m.s)
...@@ -538,7 +538,7 @@ func initdynimport(ctxt *Link) *Dll { ...@@ -538,7 +538,7 @@ func initdynimport(ctxt *Link) *Dll {
} }
} }
} else { } else {
dynamic := Linklookup(ctxt, ".windynamic", 0) dynamic := ctxt.Syms.Lookup(".windynamic", 0)
dynamic.Attr |= AttrReachable dynamic.Attr |= AttrReachable
dynamic.Type = obj.SWINDOWS dynamic.Type = obj.SWINDOWS
for d := dr; d != nil; d = d.next { for d := dr; d != nil; d = d.next {
...@@ -571,7 +571,7 @@ func peimporteddlls() []string { ...@@ -571,7 +571,7 @@ func peimporteddlls() []string {
func addimports(ctxt *Link, datsect *IMAGE_SECTION_HEADER) { func addimports(ctxt *Link, datsect *IMAGE_SECTION_HEADER) {
startoff := coutbuf.Offset() startoff := coutbuf.Offset()
dynamic := Linklookup(ctxt, ".windynamic", 0) dynamic := ctxt.Syms.Lookup(".windynamic", 0)
// skip import descriptor table (will write it later) // skip import descriptor table (will write it later)
n := uint64(0) n := uint64(0)
...@@ -868,7 +868,7 @@ func peemitreloc(ctxt *Link, text, data, ctors *IMAGE_SECTION_HEADER) { ...@@ -868,7 +868,7 @@ func peemitreloc(ctxt *Link, text, data, ctors *IMAGE_SECTION_HEADER) {
} }
data.NumberOfRelocations = uint16(n - 1) data.NumberOfRelocations = uint16(n - 1)
dottext := Linklookup(ctxt, ".text", 0) dottext := ctxt.Syms.Lookup(".text", 0)
ctors.NumberOfRelocations = 1 ctors.NumberOfRelocations = 1
ctors.PointerToRelocations = uint32(coutbuf.Offset()) ctors.PointerToRelocations = uint32(coutbuf.Offset())
sectoff := ctors.VirtualAddress sectoff := ctors.VirtualAddress
...@@ -887,7 +887,7 @@ func peemitreloc(ctxt *Link, text, data, ctors *IMAGE_SECTION_HEADER) { ...@@ -887,7 +887,7 @@ func peemitreloc(ctxt *Link, text, data, ctors *IMAGE_SECTION_HEADER) {
func (ctxt *Link) dope() { func (ctxt *Link) dope() {
/* relocation table */ /* relocation table */
rel := Linklookup(ctxt, ".rel", 0) rel := ctxt.Syms.Lookup(".rel", 0)
rel.Attr |= AttrReachable rel.Attr |= AttrReachable
rel.Type = obj.SELFROSECT rel.Type = obj.SELFROSECT
...@@ -1002,7 +1002,7 @@ func writePESymTableRecords(ctxt *Link) int { ...@@ -1002,7 +1002,7 @@ func writePESymTableRecords(ctxt *Link) int {
} }
} }
s := Linklookup(ctxt, ".text", 0) s := ctxt.Syms.Lookup(".text", 0)
if s.Type == obj.STEXT { if s.Type == obj.STEXT {
put(ctxt, s, s.Name, TextSym, s.Value, nil) put(ctxt, s, s.Name, TextSym, s.Value, nil)
} }
...@@ -1111,7 +1111,7 @@ func addinitarray(ctxt *Link) (c *IMAGE_SECTION_HEADER) { ...@@ -1111,7 +1111,7 @@ func addinitarray(ctxt *Link) (c *IMAGE_SECTION_HEADER) {
Cseek(int64(c.PointerToRawData)) Cseek(int64(c.PointerToRawData))
chksectoff(ctxt, c, coutbuf.Offset()) chksectoff(ctxt, c, coutbuf.Offset())
init_entry := Linklookup(ctxt, *flagEntrySymbol, 0) init_entry := ctxt.Syms.Lookup(*flagEntrySymbol, 0)
addr := uint64(init_entry.Value) - init_entry.Sect.Vaddr addr := uint64(init_entry.Value) - init_entry.Sect.Vaddr
switch obj.GOARCH { switch obj.GOARCH {
......
...@@ -331,14 +331,14 @@ func (ctxt *Link) symtab() { ...@@ -331,14 +331,14 @@ func (ctxt *Link) symtab() {
ctxt.xdefine("runtime.esymtab", obj.SRODATA, 0) ctxt.xdefine("runtime.esymtab", obj.SRODATA, 0)
// garbage collection symbols // garbage collection symbols
s := Linklookup(ctxt, "runtime.gcdata", 0) s := ctxt.Syms.Lookup("runtime.gcdata", 0)
s.Type = obj.SRODATA s.Type = obj.SRODATA
s.Size = 0 s.Size = 0
s.Attr |= AttrReachable s.Attr |= AttrReachable
ctxt.xdefine("runtime.egcdata", obj.SRODATA, 0) ctxt.xdefine("runtime.egcdata", obj.SRODATA, 0)
s = Linklookup(ctxt, "runtime.gcbss", 0) s = ctxt.Syms.Lookup("runtime.gcbss", 0)
s.Type = obj.SRODATA s.Type = obj.SRODATA
s.Size = 0 s.Size = 0
s.Attr |= AttrReachable s.Attr |= AttrReachable
...@@ -348,21 +348,21 @@ func (ctxt *Link) symtab() { ...@@ -348,21 +348,21 @@ func (ctxt *Link) symtab() {
var symtype *Symbol var symtype *Symbol
var symtyperel *Symbol var symtyperel *Symbol
if UseRelro() && (Buildmode == BuildmodeCArchive || Buildmode == BuildmodeCShared || Buildmode == BuildmodePIE) { if UseRelro() && (Buildmode == BuildmodeCArchive || Buildmode == BuildmodeCShared || Buildmode == BuildmodePIE) {
s = Linklookup(ctxt, "type.*", 0) s = ctxt.Syms.Lookup("type.*", 0)
s.Type = obj.STYPE s.Type = obj.STYPE
s.Size = 0 s.Size = 0
s.Attr |= AttrReachable s.Attr |= AttrReachable
symtype = s symtype = s
s = Linklookup(ctxt, "typerel.*", 0) s = ctxt.Syms.Lookup("typerel.*", 0)
s.Type = obj.STYPERELRO s.Type = obj.STYPERELRO
s.Size = 0 s.Size = 0
s.Attr |= AttrReachable s.Attr |= AttrReachable
symtyperel = s symtyperel = s
} else if !ctxt.DynlinkingGo() { } else if !ctxt.DynlinkingGo() {
s = Linklookup(ctxt, "type.*", 0) s = ctxt.Syms.Lookup("type.*", 0)
s.Type = obj.STYPE s.Type = obj.STYPE
s.Size = 0 s.Size = 0
...@@ -372,7 +372,7 @@ func (ctxt *Link) symtab() { ...@@ -372,7 +372,7 @@ func (ctxt *Link) symtab() {
} }
groupSym := func(name string, t obj.SymKind) *Symbol { groupSym := func(name string, t obj.SymKind) *Symbol {
s := Linklookup(ctxt, name, 0) s := ctxt.Syms.Lookup(name, 0)
s.Type = t s.Type = t
s.Size = 0 s.Size = 0
s.Attr |= AttrLocal | AttrReachable s.Attr |= AttrLocal | AttrReachable
...@@ -394,13 +394,13 @@ func (ctxt *Link) symtab() { ...@@ -394,13 +394,13 @@ func (ctxt *Link) symtab() {
} }
} }
symtypelink := Linklookup(ctxt, "runtime.typelink", 0) symtypelink := ctxt.Syms.Lookup("runtime.typelink", 0)
symtypelink.Type = obj.STYPELINK symtypelink.Type = obj.STYPELINK
symitablink := Linklookup(ctxt, "runtime.itablink", 0) symitablink := ctxt.Syms.Lookup("runtime.itablink", 0)
symitablink.Type = obj.SITABLINK symitablink.Type = obj.SITABLINK
symt = Linklookup(ctxt, "runtime.symtab", 0) symt = ctxt.Syms.Lookup("runtime.symtab", 0)
symt.Attr |= AttrLocal symt.Attr |= AttrLocal
symt.Type = obj.SSYMTAB symt.Type = obj.SSYMTAB
symt.Size = 0 symt.Size = 0
...@@ -484,10 +484,10 @@ func (ctxt *Link) symtab() { ...@@ -484,10 +484,10 @@ func (ctxt *Link) symtab() {
} }
if Buildmode == BuildmodeShared { if Buildmode == BuildmodeShared {
abihashgostr := Linklookup(ctxt, "go.link.abihash."+filepath.Base(*flagOutfile), 0) abihashgostr := ctxt.Syms.Lookup("go.link.abihash."+filepath.Base(*flagOutfile), 0)
abihashgostr.Attr |= AttrReachable abihashgostr.Attr |= AttrReachable
abihashgostr.Type = obj.SRODATA abihashgostr.Type = obj.SRODATA
hashsym := Linklookup(ctxt, "go.link.abihashbytes", 0) hashsym := ctxt.Syms.Lookup("go.link.abihashbytes", 0)
Addaddr(ctxt, abihashgostr, hashsym) Addaddr(ctxt, abihashgostr, hashsym)
adduint(ctxt, abihashgostr, uint64(hashsym.Size)) adduint(ctxt, abihashgostr, uint64(hashsym.Size))
} }
...@@ -498,49 +498,49 @@ func (ctxt *Link) symtab() { ...@@ -498,49 +498,49 @@ func (ctxt *Link) symtab() {
// This code uses several global variables that are set by pcln.go:pclntab. // This code uses several global variables that are set by pcln.go:pclntab.
moduledata := ctxt.Moduledata moduledata := ctxt.Moduledata
// The pclntab slice // The pclntab slice
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.pclntab", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.pclntab", 0))
adduint(ctxt, moduledata, uint64(Linklookup(ctxt, "runtime.pclntab", 0).Size)) adduint(ctxt, moduledata, uint64(ctxt.Syms.Lookup("runtime.pclntab", 0).Size))
adduint(ctxt, moduledata, uint64(Linklookup(ctxt, "runtime.pclntab", 0).Size)) adduint(ctxt, moduledata, uint64(ctxt.Syms.Lookup("runtime.pclntab", 0).Size))
// The ftab slice // The ftab slice
Addaddrplus(ctxt, moduledata, Linklookup(ctxt, "runtime.pclntab", 0), int64(pclntabPclntabOffset)) Addaddrplus(ctxt, moduledata, ctxt.Syms.Lookup("runtime.pclntab", 0), int64(pclntabPclntabOffset))
adduint(ctxt, moduledata, uint64(pclntabNfunc+1)) adduint(ctxt, moduledata, uint64(pclntabNfunc+1))
adduint(ctxt, moduledata, uint64(pclntabNfunc+1)) adduint(ctxt, moduledata, uint64(pclntabNfunc+1))
// The filetab slice // The filetab slice
Addaddrplus(ctxt, moduledata, Linklookup(ctxt, "runtime.pclntab", 0), int64(pclntabFiletabOffset)) Addaddrplus(ctxt, moduledata, ctxt.Syms.Lookup("runtime.pclntab", 0), int64(pclntabFiletabOffset))
adduint(ctxt, moduledata, uint64(len(ctxt.Filesyms))+1) adduint(ctxt, moduledata, uint64(len(ctxt.Filesyms))+1)
adduint(ctxt, moduledata, uint64(len(ctxt.Filesyms))+1) adduint(ctxt, moduledata, uint64(len(ctxt.Filesyms))+1)
// findfunctab // findfunctab
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.findfunctab", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.findfunctab", 0))
// minpc, maxpc // minpc, maxpc
Addaddr(ctxt, moduledata, pclntabFirstFunc) Addaddr(ctxt, moduledata, pclntabFirstFunc)
Addaddrplus(ctxt, moduledata, pclntabLastFunc, pclntabLastFunc.Size) Addaddrplus(ctxt, moduledata, pclntabLastFunc, pclntabLastFunc.Size)
// pointers to specific parts of the module // pointers to specific parts of the module
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.text", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.text", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.etext", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.etext", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.noptrdata", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.noptrdata", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.enoptrdata", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.enoptrdata", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.data", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.data", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.edata", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.edata", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.bss", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.bss", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.ebss", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.ebss", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.noptrbss", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.noptrbss", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.enoptrbss", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.enoptrbss", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.end", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.end", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.gcdata", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.gcdata", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.gcbss", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.gcbss", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.types", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.types", 0))
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.etypes", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.etypes", 0))
// The typelinks slice // The typelinks slice
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.typelink", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.typelink", 0))
adduint(ctxt, moduledata, uint64(ntypelinks)) adduint(ctxt, moduledata, uint64(ntypelinks))
adduint(ctxt, moduledata, uint64(ntypelinks)) adduint(ctxt, moduledata, uint64(ntypelinks))
// The itablinks slice // The itablinks slice
Addaddr(ctxt, moduledata, Linklookup(ctxt, "runtime.itablink", 0)) Addaddr(ctxt, moduledata, ctxt.Syms.Lookup("runtime.itablink", 0))
adduint(ctxt, moduledata, uint64(nitablinks)) adduint(ctxt, moduledata, uint64(nitablinks))
adduint(ctxt, moduledata, uint64(nitablinks)) adduint(ctxt, moduledata, uint64(nitablinks))
// The ptab slice // The ptab slice
if Buildmode == BuildmodePlugin { if Buildmode == BuildmodePlugin {
ptab := Linkrlookup(ctxt, "go.plugin.tabs", 0) ptab := ctxt.Syms.ROLookup("go.plugin.tabs", 0)
ptab.Attr |= AttrReachable ptab.Attr |= AttrReachable
ptab.Attr |= AttrLocal ptab.Attr |= AttrLocal
ptab.Type = obj.SRODATA ptab.Type = obj.SRODATA
...@@ -564,7 +564,7 @@ func (ctxt *Link) symtab() { ...@@ -564,7 +564,7 @@ func (ctxt *Link) symtab() {
} }
addgostring(ctxt, moduledata, "go.link.thismodulename", thismodulename) addgostring(ctxt, moduledata, "go.link.thismodulename", thismodulename)
modulehashes := Linklookup(ctxt, "go.link.abihashes", 0) modulehashes := ctxt.Syms.Lookup("go.link.abihashes", 0)
modulehashes.Attr |= AttrReachable modulehashes.Attr |= AttrReachable
modulehashes.Attr |= AttrLocal modulehashes.Attr |= AttrLocal
modulehashes.Type = obj.SRODATA modulehashes.Type = obj.SRODATA
...@@ -578,7 +578,7 @@ func (ctxt *Link) symtab() { ...@@ -578,7 +578,7 @@ func (ctxt *Link) symtab() {
addgostring(ctxt, modulehashes, fmt.Sprintf("go.link.linkhash.%d", i), string(shlib.Hash)) addgostring(ctxt, modulehashes, fmt.Sprintf("go.link.linkhash.%d", i), string(shlib.Hash))
// modulehashes[i].runtimehash // modulehashes[i].runtimehash
abihash := Linklookup(ctxt, "go.link.abihash."+modulename, 0) abihash := ctxt.Syms.Lookup("go.link.abihash."+modulename, 0)
abihash.Attr |= AttrReachable abihash.Attr |= AttrReachable
Addaddr(ctxt, modulehashes, abihash) Addaddr(ctxt, modulehashes, abihash)
} }
...@@ -592,11 +592,11 @@ func (ctxt *Link) symtab() { ...@@ -592,11 +592,11 @@ func (ctxt *Link) symtab() {
// When linking an object that does not contain the runtime we are // When linking an object that does not contain the runtime we are
// creating the moduledata from scratch and it does not have a // creating the moduledata from scratch and it does not have a
// compiler-provided size, so read it from the type data. // compiler-provided size, so read it from the type data.
moduledatatype := Linkrlookup(ctxt, "type.runtime.moduledata", 0) moduledatatype := ctxt.Syms.ROLookup("type.runtime.moduledata", 0)
moduledata.Size = decodetypeSize(ctxt.Arch, moduledatatype) moduledata.Size = decodetypeSize(ctxt.Arch, moduledatatype)
Symgrow(ctxt, moduledata, moduledata.Size) Symgrow(ctxt, moduledata, moduledata.Size)
lastmoduledatap := Linklookup(ctxt, "runtime.lastmoduledatap", 0) lastmoduledatap := ctxt.Syms.Lookup("runtime.lastmoduledatap", 0)
if lastmoduledatap.Type != obj.SDYNIMPORT { if lastmoduledatap.Type != obj.SDYNIMPORT {
lastmoduledatap.Type = obj.SNOPTRDATA lastmoduledatap.Type = obj.SNOPTRDATA
lastmoduledatap.Size = 0 // overwrite existing value lastmoduledatap.Size = 0 // overwrite existing value
......
...@@ -143,7 +143,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int { ...@@ -143,7 +143,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
return 0 return 0
case obj.R_GOTOFF: case obj.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ld.Linklookup(ctxt, ".got", 0)) *val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
return 0 return 0
case obj.R_ADDRMIPS, case obj.R_ADDRMIPS,
...@@ -266,7 +266,7 @@ func asmb(ctxt *ld.Link) { ...@@ -266,7 +266,7 @@ func asmb(ctxt *ld.Link) {
ld.Asmplan9sym(ctxt) ld.Asmplan9sym(ctxt)
ld.Cflush() ld.Cflush()
sym := ld.Linklookup(ctxt, "pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { for i := 0; int32(i) < ld.Lcsize; i++ {
......
...@@ -101,7 +101,7 @@ func genplt(ctxt *ld.Link) { ...@@ -101,7 +101,7 @@ func genplt(ctxt *ld.Link) {
// Generate call stub // Generate call stub
n := fmt.Sprintf("%s.%s", s.Name, r.Sym.Name) n := fmt.Sprintf("%s.%s", s.Name, r.Sym.Name)
stub := ld.Linklookup(ctxt, n, 0) stub := ctxt.Syms.Lookup(n, 0)
if s.Attr.Reachable() { if s.Attr.Reachable() {
stub.Attr |= ld.AttrReachable stub.Attr |= ld.AttrReachable
} }
...@@ -124,12 +124,12 @@ func genplt(ctxt *ld.Link) { ...@@ -124,12 +124,12 @@ func genplt(ctxt *ld.Link) {
} }
func genaddmoduledata(ctxt *ld.Link) { func genaddmoduledata(ctxt *ld.Link) {
addmoduledata := ld.Linkrlookup(ctxt, "runtime.addmoduledata", 0) addmoduledata := ctxt.Syms.ROLookup("runtime.addmoduledata", 0)
if addmoduledata.Type == obj.STEXT { if addmoduledata.Type == obj.STEXT {
return return
} }
addmoduledata.Attr |= ld.AttrReachable addmoduledata.Attr |= ld.AttrReachable
initfunc := ld.Linklookup(ctxt, "go.link.addmoduledata", 0) initfunc := ctxt.Syms.Lookup("go.link.addmoduledata", 0)
initfunc.Type = obj.STEXT initfunc.Type = obj.STEXT
initfunc.Attr |= ld.AttrLocal initfunc.Attr |= ld.AttrLocal
initfunc.Attr |= ld.AttrReachable initfunc.Attr |= ld.AttrReachable
...@@ -140,7 +140,7 @@ func genaddmoduledata(ctxt *ld.Link) { ...@@ -140,7 +140,7 @@ func genaddmoduledata(ctxt *ld.Link) {
rel := ld.Addrel(initfunc) rel := ld.Addrel(initfunc)
rel.Off = int32(initfunc.Size) rel.Off = int32(initfunc.Size)
rel.Siz = 8 rel.Siz = 8
rel.Sym = ld.Linklookup(ctxt, ".TOC.", 0) rel.Sym = ctxt.Syms.Lookup(".TOC.", 0)
rel.Type = obj.R_ADDRPOWER_PCREL rel.Type = obj.R_ADDRPOWER_PCREL
o(0x3c4c0000) o(0x3c4c0000)
// addi r2, r2, .TOC.-func@l // addi r2, r2, .TOC.-func@l
...@@ -153,7 +153,7 @@ func genaddmoduledata(ctxt *ld.Link) { ...@@ -153,7 +153,7 @@ func genaddmoduledata(ctxt *ld.Link) {
rel = ld.Addrel(initfunc) rel = ld.Addrel(initfunc)
rel.Off = int32(initfunc.Size) rel.Off = int32(initfunc.Size)
rel.Siz = 8 rel.Siz = 8
rel.Sym = ld.Linklookup(ctxt, "local.moduledata", 0) rel.Sym = ctxt.Syms.Lookup("local.moduledata", 0)
rel.Type = obj.R_ADDRPOWER_GOT rel.Type = obj.R_ADDRPOWER_GOT
o(0x3c620000) o(0x3c620000)
// ld r3, local.moduledata@got@l(r3) // ld r3, local.moduledata@got@l(r3)
...@@ -177,7 +177,7 @@ func genaddmoduledata(ctxt *ld.Link) { ...@@ -177,7 +177,7 @@ func genaddmoduledata(ctxt *ld.Link) {
o(0x4e800020) o(0x4e800020)
ctxt.Textp = append(ctxt.Textp, initfunc) ctxt.Textp = append(ctxt.Textp, initfunc)
initarray_entry := ld.Linklookup(ctxt, "go.link.addmoduledatainit", 0) initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0)
initarray_entry.Attr |= ld.AttrReachable initarray_entry.Attr |= ld.AttrReachable
initarray_entry.Attr |= ld.AttrLocal initarray_entry.Attr |= ld.AttrLocal
initarray_entry.Type = obj.SINITARR initarray_entry.Type = obj.SINITARR
...@@ -203,7 +203,7 @@ func gencallstub(ctxt *ld.Link, abicase int, stub *ld.Symbol, targ *ld.Symbol) { ...@@ -203,7 +203,7 @@ func gencallstub(ctxt *ld.Link, abicase int, stub *ld.Symbol, targ *ld.Symbol) {
log.Fatalf("gencallstub only implements case 1 calls") log.Fatalf("gencallstub only implements case 1 calls")
} }
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
stub.Type = obj.STEXT stub.Type = obj.STEXT
...@@ -284,7 +284,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -284,7 +284,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
// These happen in .toc sections // These happen in .toc sections
ld.Adddynsym(ctxt, targ) ld.Adddynsym(ctxt, targ)
rela := ld.Linklookup(ctxt, ".rela", 0) rela := ctxt.Syms.Lookup(".rela", 0)
ld.Addaddrplus(ctxt, rela, s, int64(r.Off)) ld.Addaddrplus(ctxt, rela, s, int64(r.Off))
ld.Adduint64(ctxt, rela, ld.ELF64_R_INFO(uint32(targ.Dynid), ld.R_PPC64_ADDR64)) ld.Adduint64(ctxt, rela, ld.ELF64_R_INFO(uint32(targ.Dynid), ld.R_PPC64_ADDR64))
ld.Adduint64(ctxt, rela, uint64(r.Add)) ld.Adduint64(ctxt, rela, uint64(r.Add))
...@@ -432,7 +432,7 @@ func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int { ...@@ -432,7 +432,7 @@ func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
} }
func elfsetupplt(ctxt *ld.Link) { func elfsetupplt(ctxt *ld.Link) {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
if plt.Size == 0 { if plt.Size == 0 {
// The dynamic linker stores the address of the // The dynamic linker stores the address of the
// dynamic resolver and the DSO identifier in the two // dynamic resolver and the DSO identifier in the two
...@@ -451,9 +451,9 @@ func symtoc(ctxt *ld.Link, s *ld.Symbol) int64 { ...@@ -451,9 +451,9 @@ func symtoc(ctxt *ld.Link, s *ld.Symbol) int64 {
var toc *ld.Symbol var toc *ld.Symbol
if s.Outer != nil { if s.Outer != nil {
toc = ld.Linkrlookup(ctxt, ".TOC.", int(s.Outer.Version)) toc = ctxt.Syms.ROLookup(".TOC.", int(s.Outer.Version))
} else { } else {
toc = ld.Linkrlookup(ctxt, ".TOC.", int(s.Version)) toc = ctxt.Syms.ROLookup(".TOC.", int(s.Version))
} }
if toc == nil { if toc == nil {
...@@ -563,7 +563,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int { ...@@ -563,7 +563,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
return 0 return 0
case obj.R_GOTOFF: case obj.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ld.Linklookup(ctxt, ".got", 0)) *val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
return 0 return 0
case obj.R_ADDRPOWER, obj.R_ADDRPOWER_DS: case obj.R_ADDRPOWER, obj.R_ADDRPOWER_DS:
...@@ -705,8 +705,8 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -705,8 +705,8 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) {
ld.Adddynsym(ctxt, s) ld.Adddynsym(ctxt, s)
if ld.Iself { if ld.Iself {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
rela := ld.Linklookup(ctxt, ".rela.plt", 0) rela := ctxt.Syms.Lookup(".rela.plt", 0)
if plt.Size == 0 { if plt.Size == 0 {
elfsetupplt(ctxt) elfsetupplt(ctxt)
} }
...@@ -744,7 +744,7 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -744,7 +744,7 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) {
// Generate the glink resolver stub if necessary and return the .glink section // Generate the glink resolver stub if necessary and return the .glink section
func ensureglinkresolver(ctxt *ld.Link) *ld.Symbol { func ensureglinkresolver(ctxt *ld.Link) *ld.Symbol {
glink := ld.Linklookup(ctxt, ".glink", 0) glink := ctxt.Syms.Lookup(".glink", 0)
if glink.Size != 0 { if glink.Size != 0 {
return glink return glink
} }
...@@ -774,7 +774,7 @@ func ensureglinkresolver(ctxt *ld.Link) *ld.Symbol { ...@@ -774,7 +774,7 @@ func ensureglinkresolver(ctxt *ld.Link) *ld.Symbol {
r := ld.Addrel(glink) r := ld.Addrel(glink)
r.Off = int32(glink.Size) r.Off = int32(glink.Size)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Siz = 8 r.Siz = 8
r.Type = obj.R_ADDRPOWER r.Type = obj.R_ADDRPOWER
...@@ -795,7 +795,7 @@ func ensureglinkresolver(ctxt *ld.Link) *ld.Symbol { ...@@ -795,7 +795,7 @@ func ensureglinkresolver(ctxt *ld.Link) *ld.Symbol {
// Add DT_PPC64_GLINK .dynamic entry, which points to 32 bytes // Add DT_PPC64_GLINK .dynamic entry, which points to 32 bytes
// before the first symbol resolver stub. // before the first symbol resolver stub.
s := ld.Linklookup(ctxt, ".dynamic", 0) s := ctxt.Syms.Lookup(".dynamic", 0)
ld.Elfwritedynentsymplus(ctxt, s, ld.DT_PPC64_GLINK, glink, glink.Size-32) ld.Elfwritedynentsymplus(ctxt, s, ld.DT_PPC64_GLINK, glink, glink.Size-32)
...@@ -885,7 +885,7 @@ func asmb(ctxt *ld.Link) { ...@@ -885,7 +885,7 @@ func asmb(ctxt *ld.Link) {
ld.Asmplan9sym(ctxt) ld.Asmplan9sym(ctxt)
ld.Cflush() ld.Cflush()
sym := ld.Linklookup(ctxt, "pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { for i := 0; int32(i) < ld.Lcsize; i++ {
......
...@@ -51,14 +51,14 @@ func gentext(ctxt *ld.Link) { ...@@ -51,14 +51,14 @@ func gentext(ctxt *ld.Link) {
if !ctxt.DynlinkingGo() { if !ctxt.DynlinkingGo() {
return return
} }
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0) addmoduledata := ctxt.Syms.Lookup("runtime.addmoduledata", 0)
if addmoduledata.Type == obj.STEXT { if addmoduledata.Type == obj.STEXT {
// we're linking a module containing the runtime -> no need for // we're linking a module containing the runtime -> no need for
// an init function // an init function
return return
} }
addmoduledata.Attr |= ld.AttrReachable addmoduledata.Attr |= ld.AttrReachable
initfunc := ld.Linklookup(ctxt, "go.link.addmoduledata", 0) initfunc := ctxt.Syms.Lookup("go.link.addmoduledata", 0)
initfunc.Type = obj.STEXT initfunc.Type = obj.STEXT
initfunc.Attr |= ld.AttrLocal initfunc.Attr |= ld.AttrLocal
initfunc.Attr |= ld.AttrReachable initfunc.Attr |= ld.AttrReachable
...@@ -81,7 +81,7 @@ func gentext(ctxt *ld.Link) { ...@@ -81,7 +81,7 @@ func gentext(ctxt *ld.Link) {
rel := ld.Addrel(initfunc) rel := ld.Addrel(initfunc)
rel.Off = int32(initfunc.Size) rel.Off = int32(initfunc.Size)
rel.Siz = 4 rel.Siz = 4
rel.Sym = ld.Linklookup(ctxt, "runtime.addmoduledata", 0) rel.Sym = ctxt.Syms.Lookup("runtime.addmoduledata", 0)
rel.Type = obj.R_CALL rel.Type = obj.R_CALL
rel.Variant = ld.RV_390_DBL rel.Variant = ld.RV_390_DBL
rel.Add = 2 + int64(rel.Siz) rel.Add = 2 + int64(rel.Siz)
...@@ -91,7 +91,7 @@ func gentext(ctxt *ld.Link) { ...@@ -91,7 +91,7 @@ func gentext(ctxt *ld.Link) {
ld.Adduint32(ctxt, initfunc, 0) ld.Adduint32(ctxt, initfunc, 0)
ctxt.Textp = append(ctxt.Textp, initfunc) ctxt.Textp = append(ctxt.Textp, initfunc)
initarray_entry := ld.Linklookup(ctxt, "go.link.addmoduledatainit", 0) initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0)
initarray_entry.Attr |= ld.AttrLocal initarray_entry.Attr |= ld.AttrLocal
initarray_entry.Attr |= ld.AttrReachable initarray_entry.Attr |= ld.AttrReachable
initarray_entry.Type = obj.SINITARR initarray_entry.Type = obj.SINITARR
...@@ -150,7 +150,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -150,7 +150,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
if targ.Type == obj.SDYNIMPORT { if targ.Type == obj.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add += int64(targ.Plt) r.Add += int64(targ.Plt)
} }
return true return true
...@@ -161,7 +161,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -161,7 +161,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
if targ.Type == obj.SDYNIMPORT { if targ.Type == obj.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add += int64(targ.Plt) r.Add += int64(targ.Plt)
} }
return true return true
...@@ -191,7 +191,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -191,7 +191,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
case 256 + ld.R_390_GOTPC: case 256 + ld.R_390_GOTPC:
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
return true return true
...@@ -208,7 +208,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -208,7 +208,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
case 256 + ld.R_390_GOTPCDBL: case 256 + ld.R_390_GOTPCDBL:
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
r.Variant = ld.RV_390_DBL r.Variant = ld.RV_390_DBL
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
return true return true
...@@ -217,7 +217,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -217,7 +217,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
r.Variant = ld.RV_390_DBL r.Variant = ld.RV_390_DBL
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += int64(targ.Got) r.Add += int64(targ.Got)
r.Add += int64(r.Siz) r.Add += int64(r.Siz)
return true return true
...@@ -330,8 +330,8 @@ func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int { ...@@ -330,8 +330,8 @@ func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
} }
func elfsetupplt(ctxt *ld.Link) { func elfsetupplt(ctxt *ld.Link) {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
got := ld.Linklookup(ctxt, ".got", 0) got := ctxt.Syms.Lookup(".got", 0)
if plt.Size == 0 { if plt.Size == 0 {
// stg %r1,56(%r15) // stg %r1,56(%r15)
ld.Adduint8(ctxt, plt, 0xe3) ld.Adduint8(ctxt, plt, 0xe3)
...@@ -372,7 +372,7 @@ func elfsetupplt(ctxt *ld.Link) { ...@@ -372,7 +372,7 @@ func elfsetupplt(ctxt *ld.Link) {
ld.Adduint8(ctxt, plt, 0x00) ld.Adduint8(ctxt, plt, 0x00)
// assume got->size == 0 too // assume got->size == 0 too
ld.Addaddrplus(ctxt, got, ld.Linklookup(ctxt, ".dynamic", 0), 0) ld.Addaddrplus(ctxt, got, ctxt.Syms.Lookup(".dynamic", 0), 0)
ld.Adduint64(ctxt, got, 0) ld.Adduint64(ctxt, got, 0)
ld.Adduint64(ctxt, got, 0) ld.Adduint64(ctxt, got, 0)
...@@ -394,7 +394,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int { ...@@ -394,7 +394,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
return 0 return 0
case obj.R_GOTOFF: case obj.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ld.Linklookup(ctxt, ".got", 0)) *val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
return 0 return 0
} }
...@@ -426,9 +426,9 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -426,9 +426,9 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) {
ld.Adddynsym(ctxt, s) ld.Adddynsym(ctxt, s)
if ld.Iself { if ld.Iself {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
got := ld.Linklookup(ctxt, ".got", 0) got := ctxt.Syms.Lookup(".got", 0)
rela := ld.Linklookup(ctxt, ".rela.plt", 0) rela := ctxt.Syms.Lookup(".rela.plt", 0)
if plt.Size == 0 { if plt.Size == 0 {
elfsetupplt(ctxt) elfsetupplt(ctxt)
} }
...@@ -487,12 +487,12 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -487,12 +487,12 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) {
} }
ld.Adddynsym(ctxt, s) ld.Adddynsym(ctxt, s)
got := ld.Linklookup(ctxt, ".got", 0) got := ctxt.Syms.Lookup(".got", 0)
s.Got = int32(got.Size) s.Got = int32(got.Size)
ld.Adduint64(ctxt, got, 0) ld.Adduint64(ctxt, got, 0)
if ld.Iself { if ld.Iself {
rela := ld.Linklookup(ctxt, ".rela", 0) rela := ctxt.Syms.Lookup(".rela", 0)
ld.Addaddrplus(ctxt, rela, got, int64(s.Got)) ld.Addaddrplus(ctxt, rela, got, int64(s.Got))
ld.Adduint64(ctxt, rela, ld.ELF64_R_INFO(uint32(s.Dynid), ld.R_390_GLOB_DAT)) ld.Adduint64(ctxt, rela, ld.ELF64_R_INFO(uint32(s.Dynid), ld.R_390_GLOB_DAT))
ld.Adduint64(ctxt, rela, 0) ld.Adduint64(ctxt, rela, 0)
......
...@@ -79,7 +79,7 @@ func gentext(ctxt *ld.Link) { ...@@ -79,7 +79,7 @@ func gentext(ctxt *ld.Link) {
{"si", 6}, {"si", 6},
{"di", 7}, {"di", 7},
} { } {
thunkfunc := ld.Linklookup(ctxt, "__x86.get_pc_thunk."+r.name, 0) thunkfunc := ctxt.Syms.Lookup("__x86.get_pc_thunk."+r.name, 0)
thunkfunc.Type = obj.STEXT thunkfunc.Type = obj.STEXT
thunkfunc.Attr |= ld.AttrLocal thunkfunc.Attr |= ld.AttrLocal
thunkfunc.Attr |= ld.AttrReachable //TODO: remove? thunkfunc.Attr |= ld.AttrReachable //TODO: remove?
...@@ -97,7 +97,7 @@ func gentext(ctxt *ld.Link) { ...@@ -97,7 +97,7 @@ func gentext(ctxt *ld.Link) {
ctxt.Textp = append(ctxt.Textp, thunkfunc) ctxt.Textp = append(ctxt.Textp, thunkfunc)
} }
addmoduledata := ld.Linklookup(ctxt, "runtime.addmoduledata", 0) addmoduledata := ctxt.Syms.Lookup("runtime.addmoduledata", 0)
if addmoduledata.Type == obj.STEXT && ld.Buildmode != ld.BuildmodePlugin { if addmoduledata.Type == obj.STEXT && ld.Buildmode != ld.BuildmodePlugin {
// we're linking a module containing the runtime -> no need for // we're linking a module containing the runtime -> no need for
// an init function // an init function
...@@ -106,7 +106,7 @@ func gentext(ctxt *ld.Link) { ...@@ -106,7 +106,7 @@ func gentext(ctxt *ld.Link) {
addmoduledata.Attr |= ld.AttrReachable addmoduledata.Attr |= ld.AttrReachable
initfunc := ld.Linklookup(ctxt, "go.link.addmoduledata", 0) initfunc := ctxt.Syms.Lookup("go.link.addmoduledata", 0)
initfunc.Type = obj.STEXT initfunc.Type = obj.STEXT
initfunc.Attr |= ld.AttrLocal initfunc.Attr |= ld.AttrLocal
initfunc.Attr |= ld.AttrReachable initfunc.Attr |= ld.AttrReachable
...@@ -128,7 +128,7 @@ func gentext(ctxt *ld.Link) { ...@@ -128,7 +128,7 @@ func gentext(ctxt *ld.Link) {
o(0x53) o(0x53)
o(0xe8) o(0xe8)
addcall(ctxt, initfunc, ld.Linklookup(ctxt, "__x86.get_pc_thunk.cx", 0)) addcall(ctxt, initfunc, ctxt.Syms.Lookup("__x86.get_pc_thunk.cx", 0))
o(0x8d, 0x81) o(0x8d, 0x81)
ld.Addpcrelplus(ctxt, initfunc, ctxt.Moduledata, 6) ld.Addpcrelplus(ctxt, initfunc, ctxt.Moduledata, 6)
...@@ -138,7 +138,7 @@ func gentext(ctxt *ld.Link) { ...@@ -138,7 +138,7 @@ func gentext(ctxt *ld.Link) {
initfunc.Size += 4 initfunc.Size += 4
ld.Symgrow(ctxt, initfunc, initfunc.Size) ld.Symgrow(ctxt, initfunc, initfunc.Size)
r := ld.Addrel(initfunc) r := ld.Addrel(initfunc)
r.Sym = ld.Linklookup(ctxt, "_GLOBAL_OFFSET_TABLE_", 0) r.Sym = ctxt.Syms.Lookup("_GLOBAL_OFFSET_TABLE_", 0)
r.Off = int32(i) r.Off = int32(i)
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
r.Add = 12 r.Add = 12
...@@ -155,7 +155,7 @@ func gentext(ctxt *ld.Link) { ...@@ -155,7 +155,7 @@ func gentext(ctxt *ld.Link) {
if ld.Buildmode == ld.BuildmodePlugin { if ld.Buildmode == ld.BuildmodePlugin {
ctxt.Textp = append(ctxt.Textp, addmoduledata) ctxt.Textp = append(ctxt.Textp, addmoduledata)
} }
initarray_entry := ld.Linklookup(ctxt, "go.link.addmoduledatainit", 0) initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0)
initarray_entry.Attr |= ld.AttrReachable initarray_entry.Attr |= ld.AttrReachable
initarray_entry.Attr |= ld.AttrLocal initarray_entry.Attr |= ld.AttrLocal
initarray_entry.Type = obj.SINITARR initarray_entry.Type = obj.SINITARR
...@@ -189,7 +189,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -189,7 +189,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
r.Add += 4 r.Add += 4
if targ.Type == obj.SDYNIMPORT { if targ.Type == obj.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add += int64(targ.Plt) r.Add += int64(targ.Plt)
} }
...@@ -232,7 +232,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -232,7 +232,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
case 256 + ld.R_386_GOTPC: case 256 + ld.R_386_GOTPC:
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += 4 r.Add += 4
return true return true
...@@ -253,7 +253,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -253,7 +253,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
case 512 + ld.MACHO_GENERIC_RELOC_VANILLA*2 + 1: case 512 + ld.MACHO_GENERIC_RELOC_VANILLA*2 + 1:
if targ.Type == obj.SDYNIMPORT { if targ.Type == obj.SDYNIMPORT {
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(targ.Plt) r.Add = int64(targ.Plt)
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
return true return true
...@@ -277,7 +277,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -277,7 +277,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
} }
addgotsym(ctxt, targ) addgotsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".got", 0) r.Sym = ctxt.Syms.Lookup(".got", 0)
r.Add += int64(targ.Got) r.Add += int64(targ.Got)
r.Type = obj.R_PCREL r.Type = obj.R_PCREL
return true return true
...@@ -291,7 +291,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -291,7 +291,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
case obj.R_CALL, case obj.R_CALL,
obj.R_PCREL: obj.R_PCREL:
addpltsym(ctxt, targ) addpltsym(ctxt, targ)
r.Sym = ld.Linklookup(ctxt, ".plt", 0) r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add = int64(targ.Plt) r.Add = int64(targ.Plt)
return true return true
...@@ -301,7 +301,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -301,7 +301,7 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
} }
if ld.Iself { if ld.Iself {
ld.Adddynsym(ctxt, targ) ld.Adddynsym(ctxt, targ)
rel := ld.Linklookup(ctxt, ".rel", 0) rel := ctxt.Syms.Lookup(".rel", 0)
ld.Addaddrplus(ctxt, rel, s, int64(r.Off)) ld.Addaddrplus(ctxt, rel, s, int64(r.Off))
ld.Adduint32(ctxt, rel, ld.ELF32_R_INFO(uint32(targ.Dynid), ld.R_386_32)) ld.Adduint32(ctxt, rel, ld.ELF32_R_INFO(uint32(targ.Dynid), ld.R_386_32))
r.Type = obj.R_CONST // write r->add during relocsym r.Type = obj.R_CONST // write r->add during relocsym
...@@ -322,14 +322,14 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool { ...@@ -322,14 +322,14 @@ func adddynrel(ctxt *ld.Link, s *ld.Symbol, r *ld.Reloc) bool {
// but we only need to support cgo and that's all it needs. // but we only need to support cgo and that's all it needs.
ld.Adddynsym(ctxt, targ) ld.Adddynsym(ctxt, targ)
got := ld.Linklookup(ctxt, ".got", 0) got := ctxt.Syms.Lookup(".got", 0)
s.Type = got.Type | obj.SSUB s.Type = got.Type | obj.SSUB
s.Outer = got s.Outer = got
s.Sub = got.Sub s.Sub = got.Sub
got.Sub = s got.Sub = s
s.Value = got.Size s.Value = got.Size
ld.Adduint32(ctxt, got, 0) ld.Adduint32(ctxt, got, 0)
ld.Adduint32(ctxt, ld.Linklookup(ctxt, ".linkedit.got", 0), uint32(targ.Dynid)) ld.Adduint32(ctxt, ctxt.Syms.Lookup(".linkedit.got", 0), uint32(targ.Dynid))
r.Type = 256 // ignore during relocsym r.Type = 256 // ignore during relocsym
return true return true
} }
...@@ -503,7 +503,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int { ...@@ -503,7 +503,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
return 0 return 0
case obj.R_GOTOFF: case obj.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ld.Linklookup(ctxt, ".got", 0)) *val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
return 0 return 0
} }
...@@ -516,8 +516,8 @@ func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 { ...@@ -516,8 +516,8 @@ func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
} }
func elfsetupplt(ctxt *ld.Link) { func elfsetupplt(ctxt *ld.Link) {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
got := ld.Linklookup(ctxt, ".got.plt", 0) got := ctxt.Syms.Lookup(".got.plt", 0)
if plt.Size == 0 { if plt.Size == 0 {
// pushl got+4 // pushl got+4
ld.Adduint8(ctxt, plt, 0xff) ld.Adduint8(ctxt, plt, 0xff)
...@@ -535,7 +535,7 @@ func elfsetupplt(ctxt *ld.Link) { ...@@ -535,7 +535,7 @@ func elfsetupplt(ctxt *ld.Link) {
ld.Adduint32(ctxt, plt, 0) ld.Adduint32(ctxt, plt, 0)
// assume got->size == 0 too // assume got->size == 0 too
ld.Addaddrplus(ctxt, got, ld.Linklookup(ctxt, ".dynamic", 0), 0) ld.Addaddrplus(ctxt, got, ctxt.Syms.Lookup(".dynamic", 0), 0)
ld.Adduint32(ctxt, got, 0) ld.Adduint32(ctxt, got, 0)
ld.Adduint32(ctxt, got, 0) ld.Adduint32(ctxt, got, 0)
...@@ -550,9 +550,9 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -550,9 +550,9 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) {
ld.Adddynsym(ctxt, s) ld.Adddynsym(ctxt, s)
if ld.Iself { if ld.Iself {
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
got := ld.Linklookup(ctxt, ".got.plt", 0) got := ctxt.Syms.Lookup(".got.plt", 0)
rel := ld.Linklookup(ctxt, ".rel.plt", 0) rel := ctxt.Syms.Lookup(".rel.plt", 0)
if plt.Size == 0 { if plt.Size == 0 {
elfsetupplt(ctxt) elfsetupplt(ctxt)
} }
...@@ -585,18 +585,18 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -585,18 +585,18 @@ func addpltsym(ctxt *ld.Link, s *ld.Symbol) {
} else if ld.Headtype == obj.Hdarwin { } else if ld.Headtype == obj.Hdarwin {
// Same laziness as in 6l. // Same laziness as in 6l.
plt := ld.Linklookup(ctxt, ".plt", 0) plt := ctxt.Syms.Lookup(".plt", 0)
addgotsym(ctxt, s) addgotsym(ctxt, s)
ld.Adduint32(ctxt, ld.Linklookup(ctxt, ".linkedit.plt", 0), uint32(s.Dynid)) ld.Adduint32(ctxt, ctxt.Syms.Lookup(".linkedit.plt", 0), uint32(s.Dynid))
// jmpq *got+size(IP) // jmpq *got+size(IP)
s.Plt = int32(plt.Size) s.Plt = int32(plt.Size)
ld.Adduint8(ctxt, plt, 0xff) ld.Adduint8(ctxt, plt, 0xff)
ld.Adduint8(ctxt, plt, 0x25) ld.Adduint8(ctxt, plt, 0x25)
ld.Addaddrplus(ctxt, plt, ld.Linklookup(ctxt, ".got", 0), int64(s.Got)) ld.Addaddrplus(ctxt, plt, ctxt.Syms.Lookup(".got", 0), int64(s.Got))
} else { } else {
ld.Errorf(s, "addpltsym: unsupported binary format") ld.Errorf(s, "addpltsym: unsupported binary format")
} }
...@@ -608,16 +608,16 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -608,16 +608,16 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) {
} }
ld.Adddynsym(ctxt, s) ld.Adddynsym(ctxt, s)
got := ld.Linklookup(ctxt, ".got", 0) got := ctxt.Syms.Lookup(".got", 0)
s.Got = int32(got.Size) s.Got = int32(got.Size)
ld.Adduint32(ctxt, got, 0) ld.Adduint32(ctxt, got, 0)
if ld.Iself { if ld.Iself {
rel := ld.Linklookup(ctxt, ".rel", 0) rel := ctxt.Syms.Lookup(".rel", 0)
ld.Addaddrplus(ctxt, rel, got, int64(s.Got)) ld.Addaddrplus(ctxt, rel, got, int64(s.Got))
ld.Adduint32(ctxt, rel, ld.ELF32_R_INFO(uint32(s.Dynid), ld.R_386_GLOB_DAT)) ld.Adduint32(ctxt, rel, ld.ELF32_R_INFO(uint32(s.Dynid), ld.R_386_GLOB_DAT))
} else if ld.Headtype == obj.Hdarwin { } else if ld.Headtype == obj.Hdarwin {
ld.Adduint32(ctxt, ld.Linklookup(ctxt, ".linkedit.got", 0), uint32(s.Dynid)) ld.Adduint32(ctxt, ctxt.Syms.Lookup(".linkedit.got", 0), uint32(s.Dynid))
} else { } else {
ld.Errorf(s, "addgotsym: unsupported binary format") ld.Errorf(s, "addgotsym: unsupported binary format")
} }
...@@ -719,7 +719,7 @@ func asmb(ctxt *ld.Link) { ...@@ -719,7 +719,7 @@ func asmb(ctxt *ld.Link) {
ld.Asmplan9sym(ctxt) ld.Asmplan9sym(ctxt)
ld.Cflush() ld.Cflush()
sym := ld.Linklookup(ctxt, "pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { for i := 0; int32(i) < ld.Lcsize; i++ {
......
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