mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link: remove the second result of MakeSymbolUpdater
With unique global indices, MakeSymbolUpdater will not change the symbol's index. So no need to return a new index. Change-Id: I5b4fd6a0167cc74476880bbf4382c524ecde7721 Reviewed-on: https://go-review.googlesource.com/c/go/+/219227 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
5a8b1509dd
commit
112a7cb82c
8 changed files with 70 additions and 72 deletions
|
|
@ -202,7 +202,7 @@ func setCgoAttr(ctxt *Link, lookup func(string, int) loader.Sym, file string, pk
|
|||
l.SetSymExtname(s, remote)
|
||||
l.SetSymDynimpvers(s, q)
|
||||
if st != sym.SHOSTOBJ {
|
||||
su, _ := l.MakeSymbolUpdater(s)
|
||||
su := l.MakeSymbolUpdater(s)
|
||||
su.SetType(sym.SDYNIMPORT)
|
||||
} else {
|
||||
hostObjSyms[s] = struct{}{}
|
||||
|
|
@ -218,7 +218,8 @@ func setCgoAttr(ctxt *Link, lookup func(string, int) loader.Sym, file string, pk
|
|||
}
|
||||
local := f[1]
|
||||
|
||||
su, s := l.MakeSymbolUpdater(lookup(local, 0))
|
||||
s := lookup(local, 0)
|
||||
su := l.MakeSymbolUpdater(s)
|
||||
su.SetType(sym.SHOSTOBJ)
|
||||
su.SetSize(0)
|
||||
hostObjSyms[s] = struct{}{}
|
||||
|
|
@ -260,7 +261,7 @@ func setCgoAttr(ctxt *Link, lookup func(string, int) loader.Sym, file string, pk
|
|||
l.SetSymDynimpvers(s, "")
|
||||
l.SetSymExtname(s, "")
|
||||
var su *loader.SymbolBuilder
|
||||
su, s = l.MakeSymbolUpdater(s)
|
||||
su = l.MakeSymbolUpdater(s)
|
||||
su.SetType(0)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@ func (ctxt *Link) loadcgodirectives() {
|
|||
// cgo_import_static and cgo_import_dynamic,
|
||||
// then we want to make it cgo_import_dynamic
|
||||
// now.
|
||||
su, _ := l.MakeSymbolUpdater(symIdx)
|
||||
su := l.MakeSymbolUpdater(symIdx)
|
||||
if l.SymExtname(symIdx) != "" && l.SymDynimplib(symIdx) != "" && !(l.AttrCgoExportStatic(symIdx) || l.AttrCgoExportDynamic(symIdx)) {
|
||||
su.SetType(sym.SDYNIMPORT)
|
||||
} else {
|
||||
|
|
@ -584,12 +584,12 @@ func (ctxt *Link) linksetup() {
|
|||
switch ctxt.BuildMode {
|
||||
case BuildModeCShared, BuildModePlugin:
|
||||
symIdx := ctxt.loader.LookupOrCreateSym("runtime.islibrary", 0)
|
||||
sb, _ := ctxt.loader.MakeSymbolUpdater(symIdx)
|
||||
sb := ctxt.loader.MakeSymbolUpdater(symIdx)
|
||||
sb.SetType(sym.SNOPTRDATA)
|
||||
sb.AddUint8(1)
|
||||
case BuildModeCArchive:
|
||||
symIdx := ctxt.loader.LookupOrCreateSym("runtime.isarchive", 0)
|
||||
sb, _ := ctxt.loader.MakeSymbolUpdater(symIdx)
|
||||
sb := ctxt.loader.MakeSymbolUpdater(symIdx)
|
||||
sb.SetType(sym.SNOPTRDATA)
|
||||
sb.AddUint8(1)
|
||||
}
|
||||
|
|
@ -621,7 +621,7 @@ func (ctxt *Link) linksetup() {
|
|||
|
||||
if ctxt.LinkMode == LinkExternal && ctxt.Arch.Family == sys.PPC64 && objabi.GOOS != "aix" {
|
||||
toc := ctxt.loader.LookupOrCreateSym(".TOC.", 0)
|
||||
sb, _ := ctxt.loader.MakeSymbolUpdater(toc)
|
||||
sb := ctxt.loader.MakeSymbolUpdater(toc)
|
||||
sb.SetType(sym.SDYNIMPORT)
|
||||
}
|
||||
|
||||
|
|
@ -629,8 +629,8 @@ func (ctxt *Link) linksetup() {
|
|||
// section. We don't actually use the section on android, so don't
|
||||
// generate it.
|
||||
if objabi.GOOS != "android" {
|
||||
symIdx := ctxt.loader.LookupOrCreateSym("runtime.tlsg", 0)
|
||||
sb, tlsg := ctxt.loader.MakeSymbolUpdater(symIdx)
|
||||
tlsg := ctxt.loader.LookupOrCreateSym("runtime.tlsg", 0)
|
||||
sb := ctxt.loader.MakeSymbolUpdater(tlsg)
|
||||
|
||||
// runtime.tlsg is used for external linking on platforms that do not define
|
||||
// a variable to hold g in assembly (currently only intel).
|
||||
|
|
@ -647,12 +647,12 @@ func (ctxt *Link) linksetup() {
|
|||
var moduledata loader.Sym
|
||||
var mdsb *loader.SymbolBuilder
|
||||
if ctxt.BuildMode == BuildModePlugin {
|
||||
pmd := ctxt.loader.LookupOrCreateSym("local.pluginmoduledata", 0)
|
||||
mdsb, moduledata = ctxt.loader.MakeSymbolUpdater(pmd)
|
||||
moduledata = ctxt.loader.LookupOrCreateSym("local.pluginmoduledata", 0)
|
||||
mdsb = ctxt.loader.MakeSymbolUpdater(moduledata)
|
||||
ctxt.loader.SetAttrLocal(moduledata, true)
|
||||
} else {
|
||||
fmd := ctxt.loader.LookupOrCreateSym("runtime.firstmoduledata", 0)
|
||||
mdsb, moduledata = ctxt.loader.MakeSymbolUpdater(fmd)
|
||||
moduledata = ctxt.loader.LookupOrCreateSym("runtime.firstmoduledata", 0)
|
||||
mdsb = ctxt.loader.MakeSymbolUpdater(moduledata)
|
||||
}
|
||||
if mdsb.Type() != 0 && mdsb.Type() != sym.SDYNIMPORT {
|
||||
// If the module (toolchain-speak for "executable or shared
|
||||
|
|
@ -666,7 +666,7 @@ func (ctxt *Link) linksetup() {
|
|||
// recording the value of GOARM.
|
||||
if ctxt.Arch.Family == sys.ARM {
|
||||
goarm := ctxt.loader.LookupOrCreateSym("runtime.goarm", 0)
|
||||
sb, _ := ctxt.loader.MakeSymbolUpdater(goarm)
|
||||
sb := ctxt.loader.MakeSymbolUpdater(goarm)
|
||||
sb.SetType(sym.SDATA)
|
||||
sb.SetSize(0)
|
||||
sb.AddUint8(uint8(objabi.GOARM))
|
||||
|
|
@ -674,7 +674,7 @@ func (ctxt *Link) linksetup() {
|
|||
|
||||
if objabi.Framepointer_enabled(objabi.GOOS, objabi.GOARCH) {
|
||||
fpe := ctxt.loader.LookupOrCreateSym("runtime.framepointer_enabled", 0)
|
||||
sb, _ := ctxt.loader.MakeSymbolUpdater(fpe)
|
||||
sb := ctxt.loader.MakeSymbolUpdater(fpe)
|
||||
sb.SetType(sym.SNOPTRDATA)
|
||||
sb.SetSize(0)
|
||||
sb.AddUint8(1)
|
||||
|
|
@ -682,8 +682,8 @@ func (ctxt *Link) linksetup() {
|
|||
} else {
|
||||
// If OTOH the module does not contain the runtime package,
|
||||
// create a local symbol for the moduledata.
|
||||
lmd := ctxt.loader.LookupOrCreateSym("local.moduledata", 0)
|
||||
mdsb, moduledata = ctxt.loader.MakeSymbolUpdater(lmd)
|
||||
moduledata = ctxt.loader.LookupOrCreateSym("local.moduledata", 0)
|
||||
mdsb = ctxt.loader.MakeSymbolUpdater(moduledata)
|
||||
ctxt.loader.SetAttrLocal(moduledata, true)
|
||||
}
|
||||
// In all cases way we mark the moduledata as noptrdata to hide it from
|
||||
|
|
@ -704,8 +704,8 @@ func (ctxt *Link) linksetup() {
|
|||
|
||||
if ctxt.Arch == sys.Arch386 && ctxt.HeadType != objabi.Hwindows {
|
||||
if (ctxt.BuildMode == BuildModeCArchive && ctxt.IsELF) || ctxt.BuildMode == BuildModeCShared || ctxt.BuildMode == BuildModePIE || ctxt.DynlinkingGo() {
|
||||
symIdx := ctxt.loader.LookupOrCreateSym("_GLOBAL_OFFSET_TABLE_", 0)
|
||||
sb, got := ctxt.loader.MakeSymbolUpdater(symIdx)
|
||||
got := ctxt.loader.LookupOrCreateSym("_GLOBAL_OFFSET_TABLE_", 0)
|
||||
sb := ctxt.loader.MakeSymbolUpdater(got)
|
||||
sb.SetType(sym.SDYNIMPORT)
|
||||
ctxt.loader.SetAttrReachable(got, true)
|
||||
}
|
||||
|
|
@ -1970,16 +1970,16 @@ func ldshlibsyms(ctxt *Link, shlib string) {
|
|||
}
|
||||
|
||||
l := ctxt.loader
|
||||
symIdx := l.LookupOrCreateSym(elfsym.Name, ver)
|
||||
s := l.LookupOrCreateSym(elfsym.Name, ver)
|
||||
|
||||
// Because loadlib above loads all .a files before loading
|
||||
// any shared libraries, any non-dynimport symbols we find
|
||||
// that duplicate symbols already loaded should be ignored
|
||||
// (the symbols from the .a files "win").
|
||||
if l.SymType(symIdx) != 0 && l.SymType(symIdx) != sym.SDYNIMPORT {
|
||||
if l.SymType(s) != 0 && l.SymType(s) != sym.SDYNIMPORT {
|
||||
continue
|
||||
}
|
||||
su, s := l.MakeSymbolUpdater(symIdx)
|
||||
su := l.MakeSymbolUpdater(s)
|
||||
su.SetType(sym.SDYNIMPORT)
|
||||
l.SetSymElfType(s, elf.ST_TYPE(elfsym.Info))
|
||||
su.SetSize(int64(elfsym.Size))
|
||||
|
|
@ -2019,7 +2019,7 @@ func ldshlibsyms(ctxt *Link, shlib string) {
|
|||
if l.SymType(alias) != 0 {
|
||||
continue
|
||||
}
|
||||
su, _ := l.MakeSymbolUpdater(alias)
|
||||
su := l.MakeSymbolUpdater(alias)
|
||||
su.SetType(sym.SABIALIAS)
|
||||
su.AddReloc(loader.Reloc{Sym: s})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -721,7 +721,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
}
|
||||
sectsymNames[name] = true
|
||||
|
||||
sb, _ := l.MakeSymbolUpdater(lookup(name, localSymVersion))
|
||||
sb := l.MakeSymbolUpdater(lookup(name, localSymVersion))
|
||||
|
||||
switch int(sect.flags) & (ElfSectFlagAlloc | ElfSectFlagWrite | ElfSectFlagExec) {
|
||||
default:
|
||||
|
|
@ -768,15 +768,13 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
continue
|
||||
}
|
||||
if elfsym.shndx == ElfSymShnCommon || elfsym.type_ == ElfSymTypeCommon {
|
||||
sb, ns := l.MakeSymbolUpdater(elfsym.sym)
|
||||
sb := l.MakeSymbolUpdater(elfsym.sym)
|
||||
if uint64(sb.Size()) < elfsym.size {
|
||||
sb.SetSize(int64(elfsym.size))
|
||||
}
|
||||
if sb.Type() == 0 || sb.Type() == sym.SXREF {
|
||||
sb.SetType(sym.SNOPTRBSS)
|
||||
}
|
||||
symbols[i] = ns
|
||||
elfsym.sym = ns
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -822,8 +820,8 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
l.SymName(s), l.SymName(l.OuterSym(s)), l.SymName(sect.sym))
|
||||
}
|
||||
|
||||
sectsb, _ := l.MakeSymbolUpdater(sect.sym)
|
||||
sb, _ := l.MakeSymbolUpdater(s)
|
||||
sectsb := l.MakeSymbolUpdater(sect.sym)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
|
||||
sb.SetType(sectsb.Type())
|
||||
sectsb.PrependSub(s)
|
||||
|
|
@ -856,8 +854,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
if s == 0 {
|
||||
continue
|
||||
}
|
||||
sb, _ := l.MakeSymbolUpdater(s)
|
||||
s = sb.Sym()
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
if l.SubSym(s) != 0 {
|
||||
sb.SortSub()
|
||||
}
|
||||
|
|
@ -992,7 +989,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
sort.Sort(loader.RelocByOff(r[:n]))
|
||||
// just in case
|
||||
|
||||
sb, _ := l.MakeSymbolUpdater(sect.sym)
|
||||
sb := l.MakeSymbolUpdater(sect.sym)
|
||||
r = r[:n]
|
||||
sb.SetRelocs(r)
|
||||
}
|
||||
|
|
@ -1090,7 +1087,7 @@ func readelfsym(newSym, lookup func(string, int) loader.Sym, l *loader.Loader, a
|
|||
// comment #5 for details.
|
||||
if s != 0 && elfsym.other == 2 {
|
||||
if !l.IsExternal(s) {
|
||||
_, s = l.MakeSymbolUpdater(s)
|
||||
l.MakeSymbolUpdater(s)
|
||||
}
|
||||
l.SetAttrDuplicateOK(s, true)
|
||||
l.SetAttrVisibilityHidden(s, true)
|
||||
|
|
@ -1147,7 +1144,7 @@ func readelfsym(newSym, lookup func(string, int) loader.Sym, l *loader.Loader, a
|
|||
// TODO(mwhudson): the test of VisibilityHidden here probably doesn't make
|
||||
// sense and should be removed when someone has thought about it properly.
|
||||
if s != 0 && l.SymType(s) == 0 && !l.AttrVisibilityHidden(s) && elfsym.type_ != ElfSymTypeSection {
|
||||
sb, _ := l.MakeSymbolUpdater(s)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
sb.SetType(sym.SXREF)
|
||||
}
|
||||
elfsym.sym = s
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ func TestAddMaterializedSymbol(t *testing.T) {
|
|||
}
|
||||
|
||||
// Grab symbol builder pointers
|
||||
sb1, es1 := ldr.MakeSymbolUpdater(es1)
|
||||
sb2, es2 := ldr.MakeSymbolUpdater(es2)
|
||||
sb3, es3 := ldr.MakeSymbolUpdater(es3)
|
||||
sb1 := ldr.MakeSymbolUpdater(es1)
|
||||
sb2 := ldr.MakeSymbolUpdater(es2)
|
||||
sb3 := ldr.MakeSymbolUpdater(es3)
|
||||
|
||||
// Suppose we create some more symbols, which triggers a grow.
|
||||
// Make sure the symbol builder's payload pointer is valid,
|
||||
|
|
@ -116,8 +116,8 @@ func TestAddMaterializedSymbol(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
sb1, es1 = ldr.MakeSymbolUpdater(es1)
|
||||
sb2, es2 = ldr.MakeSymbolUpdater(es2)
|
||||
sb1 = ldr.MakeSymbolUpdater(es1)
|
||||
sb2 = ldr.MakeSymbolUpdater(es2)
|
||||
|
||||
// Get/set a few other attributes
|
||||
if ldr.AttrVisibilityHidden(es3) {
|
||||
|
|
@ -248,9 +248,9 @@ func TestAddDataMethods(t *testing.T) {
|
|||
{
|
||||
which: "AddUint8",
|
||||
addDataFunc: func(l *Loader, s Sym, _ Sym) Sym {
|
||||
sb, ns := l.MakeSymbolUpdater(s)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
sb.AddUint8('a')
|
||||
return ns
|
||||
return s
|
||||
},
|
||||
expData: []byte{'a'},
|
||||
expKind: sym.SDATA,
|
||||
|
|
@ -258,9 +258,9 @@ func TestAddDataMethods(t *testing.T) {
|
|||
{
|
||||
which: "AddUintXX",
|
||||
addDataFunc: func(l *Loader, s Sym, _ Sym) Sym {
|
||||
sb, ns := l.MakeSymbolUpdater(s)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
sb.AddUintXX(arch, 25185, 2)
|
||||
return ns
|
||||
return s
|
||||
},
|
||||
expData: []byte{'a', 'b'},
|
||||
expKind: sym.SDATA,
|
||||
|
|
@ -268,11 +268,11 @@ func TestAddDataMethods(t *testing.T) {
|
|||
{
|
||||
which: "SetUint8",
|
||||
addDataFunc: func(l *Loader, s Sym, _ Sym) Sym {
|
||||
sb, ns := l.MakeSymbolUpdater(s)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
sb.AddUint8('a')
|
||||
sb.AddUint8('b')
|
||||
sb.SetUint8(arch, 1, 'c')
|
||||
return ns
|
||||
return s
|
||||
},
|
||||
expData: []byte{'a', 'c'},
|
||||
expKind: sym.SDATA,
|
||||
|
|
@ -280,9 +280,9 @@ func TestAddDataMethods(t *testing.T) {
|
|||
{
|
||||
which: "AddString",
|
||||
addDataFunc: func(l *Loader, s Sym, _ Sym) Sym {
|
||||
sb, ns := l.MakeSymbolUpdater(s)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
sb.Addstring("hello")
|
||||
return ns
|
||||
return s
|
||||
},
|
||||
expData: []byte{'h', 'e', 'l', 'l', 'o', 0},
|
||||
expKind: sym.SNOPTRDATA,
|
||||
|
|
@ -290,9 +290,9 @@ func TestAddDataMethods(t *testing.T) {
|
|||
{
|
||||
which: "AddAddrPlus",
|
||||
addDataFunc: func(l *Loader, s Sym, s2 Sym) Sym {
|
||||
sb, ns := l.MakeSymbolUpdater(s)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
sb.AddAddrPlus(arch, s2, 3)
|
||||
return ns
|
||||
return s
|
||||
},
|
||||
expData: []byte{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
expKind: sym.SDATA,
|
||||
|
|
@ -301,9 +301,9 @@ func TestAddDataMethods(t *testing.T) {
|
|||
{
|
||||
which: "AddAddrPlus4",
|
||||
addDataFunc: func(l *Loader, s Sym, s2 Sym) Sym {
|
||||
sb, ns := l.MakeSymbolUpdater(s)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
sb.AddAddrPlus4(arch, s2, 3)
|
||||
return ns
|
||||
return s
|
||||
},
|
||||
expData: []byte{0, 0, 0, 0},
|
||||
expKind: sym.SDATA,
|
||||
|
|
@ -312,9 +312,9 @@ func TestAddDataMethods(t *testing.T) {
|
|||
{
|
||||
which: "AddCURelativeAddrPlus",
|
||||
addDataFunc: func(l *Loader, s Sym, s2 Sym) Sym {
|
||||
sb, ns := l.MakeSymbolUpdater(s)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
sb.AddCURelativeAddrPlus(arch, s2, 7)
|
||||
return ns
|
||||
return s
|
||||
},
|
||||
expData: []byte{0, 0, 0, 0, 0, 0, 0, 0},
|
||||
expKind: sym.SDATA,
|
||||
|
|
|
|||
|
|
@ -36,9 +36,8 @@ func (l *Loader) MakeSymbolBuilder(name string) *SymbolBuilder {
|
|||
// symbol 'symIdx'. If 'symIdx' is not an external symbol, then create
|
||||
// a clone of it (copy name, properties, etc) fix things up so that
|
||||
// the lookup tables and caches point to the new version, not the old
|
||||
// version. Returns a SymbolBuilder and a Sym (which may be different
|
||||
// from the original if we had to clone).
|
||||
func (l *Loader) MakeSymbolUpdater(symIdx Sym) (*SymbolBuilder, Sym) {
|
||||
// version.
|
||||
func (l *Loader) MakeSymbolUpdater(symIdx Sym) *SymbolBuilder {
|
||||
if symIdx == 0 {
|
||||
panic("can't update the null symbol")
|
||||
}
|
||||
|
|
@ -53,7 +52,7 @@ func (l *Loader) MakeSymbolUpdater(symIdx Sym) (*SymbolBuilder, Sym) {
|
|||
// Construct updater and return.
|
||||
sb := &SymbolBuilder{l: l, symIdx: symIdx}
|
||||
sb.extSymPayload = l.getPayload(symIdx)
|
||||
return sb, symIdx
|
||||
return sb
|
||||
}
|
||||
|
||||
// Getters for properties of the symbol we're working on.
|
||||
|
|
|
|||
|
|
@ -559,7 +559,8 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
continue
|
||||
}
|
||||
name := fmt.Sprintf("%s(%s/%s)", pkg, sect.segname, sect.name)
|
||||
bld, s := l.MakeSymbolUpdater(l.LookupOrCreateSym(name, localSymVersion))
|
||||
s := l.LookupOrCreateSym(name, localSymVersion)
|
||||
bld := l.MakeSymbolUpdater(s)
|
||||
if bld.Type() != 0 {
|
||||
return errorf("duplicate %s/%s", sect.segname, sect.name)
|
||||
}
|
||||
|
|
@ -624,7 +625,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
}
|
||||
|
||||
sect := &c.seg.sect[machsym.sectnum-1]
|
||||
bld, bldSym := l.MakeSymbolUpdater(s)
|
||||
bld := l.MakeSymbolUpdater(s)
|
||||
outer := sect.sym
|
||||
if outer == 0 {
|
||||
continue // ignore reference to invalid section
|
||||
|
|
@ -638,7 +639,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
}
|
||||
|
||||
bld.SetType(l.SymType(outer))
|
||||
l.PrependSub(outer, bldSym)
|
||||
l.PrependSub(outer, s)
|
||||
|
||||
bld.SetValue(int64(machsym.value - sect.addr))
|
||||
if !l.AttrCgoExportDynamic(s) {
|
||||
|
|
@ -650,26 +651,24 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
}
|
||||
bld.SetExternal(true)
|
||||
}
|
||||
|
||||
machsym.sym = bldSym
|
||||
}
|
||||
|
||||
// Sort outer lists by address, adding to textp.
|
||||
// This keeps textp in increasing address order.
|
||||
for i := 0; uint32(i) < c.seg.nsect; i++ {
|
||||
sect := &c.seg.sect[i]
|
||||
sectSym := sect.sym
|
||||
if sectSym == 0 {
|
||||
s := sect.sym
|
||||
if s == 0 {
|
||||
continue
|
||||
}
|
||||
bld, s := l.MakeSymbolUpdater(sectSym)
|
||||
bld := l.MakeSymbolUpdater(s)
|
||||
if bld.SubSym() != 0 {
|
||||
|
||||
bld.SortSub()
|
||||
|
||||
// assign sizes, now that we know symbols in sorted order.
|
||||
for s1 := bld.Sub(); s1 != 0; s1 = l.SubSym(s1) {
|
||||
s1Bld, _ := l.MakeSymbolUpdater(s1)
|
||||
s1Bld := l.MakeSymbolUpdater(s1)
|
||||
if sub := l.SubSym(s1); sub != 0 {
|
||||
s1Bld.SetSize(l.SymValue(sub) - l.SymValue(s1))
|
||||
} else {
|
||||
|
|
@ -866,7 +865,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||
}
|
||||
|
||||
sort.Sort(loader.RelocByOff(r[:rpi]))
|
||||
sb, _ := l.MakeSymbolUpdater(sect.sym)
|
||||
sb := l.MakeSymbolUpdater(sect.sym)
|
||||
sb.SetRelocs(r[:rpi])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ func makeUpdater(l *loader.Loader, bld *loader.SymbolBuilder, s loader.Sym) *loa
|
|||
if bld != nil {
|
||||
return bld
|
||||
}
|
||||
bld, _ = l.MakeSymbolUpdater(s)
|
||||
bld = l.MakeSymbolUpdater(s)
|
||||
return bld
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +160,9 @@ func makeUpdater(l *loader.Loader, bld *loader.SymbolBuilder, s loader.Sym) *loa
|
|||
// If an .rsrc section is found, its symbol is returned as rsrc.
|
||||
func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Reader, pkg string, length int64, pn string) (textp []loader.Sym, rsrc loader.Sym, err error) {
|
||||
lookup := func(name string, version int) (*loader.SymbolBuilder, loader.Sym) {
|
||||
return l.MakeSymbolUpdater(l.LookupOrCreateSym(name, version))
|
||||
s := l.LookupOrCreateSym(name, version)
|
||||
sb := l.MakeSymbolUpdater(s)
|
||||
return sb, s
|
||||
}
|
||||
sectsyms := make(map[*pe.Section]loader.Sym)
|
||||
sectdata := make(map[*pe.Section][]byte)
|
||||
|
|
@ -328,7 +330,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read
|
|||
|
||||
sort.Sort(loader.RelocByOff(rs[:rsect.NumberOfRelocations]))
|
||||
|
||||
bld, _ := l.MakeSymbolUpdater(sectsyms[rsect])
|
||||
bld := l.MakeSymbolUpdater(sectsyms[rsect])
|
||||
bld.SetRelocs(rs[:rsect.NumberOfRelocations])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read
|
|||
lds.Section = *sect
|
||||
name := fmt.Sprintf("%s(%s)", pkg, lds.Name)
|
||||
symbol := l.LookupOrCreateSym(name, localSymVersion)
|
||||
s, _ := l.MakeSymbolUpdater(symbol)
|
||||
s := l.MakeSymbolUpdater(symbol)
|
||||
|
||||
switch lds.Type {
|
||||
default:
|
||||
|
|
@ -148,7 +148,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read
|
|||
|
||||
}
|
||||
}
|
||||
bld, _ := l.MakeSymbolUpdater(sect.sym)
|
||||
bld := l.MakeSymbolUpdater(sect.sym)
|
||||
bld.SetRelocs(rs[:sect.Nreloc])
|
||||
}
|
||||
return textp, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue