mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link: propagate gotype symbol info in cloneToExternal
This patch fixes a problem with the loader's cloneToExternal method, specifically that the new external clone created did not get the proper Gotype value from its orginal symbol. Change-Id: I9978140d285104d407bf55649fb6ed94959933f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/213639 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
d5854bf8e6
commit
49e94f19f0
1 changed files with 18 additions and 0 deletions
|
|
@ -225,6 +225,7 @@ type extSymPayload struct {
|
||||||
size int64
|
size int64
|
||||||
ver int
|
ver int
|
||||||
kind sym.SymKind
|
kind sym.SymKind
|
||||||
|
gotype Sym // Gotype (0 if not present)
|
||||||
relocs []Reloc
|
relocs []Reloc
|
||||||
data []byte
|
data []byte
|
||||||
}
|
}
|
||||||
|
|
@ -1524,6 +1525,9 @@ func (l *Loader) LoadFull(arch *sys.Arch, syms *sym.Symbols) {
|
||||||
s.Type = pp.kind
|
s.Type = pp.kind
|
||||||
s.Size = pp.size
|
s.Size = pp.size
|
||||||
s.Value = l.SymValue(i)
|
s.Value = l.SymValue(i)
|
||||||
|
if pp.gotype != 0 {
|
||||||
|
s.Gotype = l.Syms[pp.gotype]
|
||||||
|
}
|
||||||
|
|
||||||
// Copy relocations
|
// Copy relocations
|
||||||
batch := l.relocBatch
|
batch := l.relocBatch
|
||||||
|
|
@ -1823,6 +1827,20 @@ func (l *Loader) cloneToExternal(symIdx Sym) Sym {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're overriding a data symbol, collect the associated
|
||||||
|
// Gotype, so as to propagate it to the new symbol.
|
||||||
|
naux := r.NAux(li)
|
||||||
|
for j := 0; j < naux; j++ {
|
||||||
|
a := goobj2.Aux{}
|
||||||
|
a.Read(r.Reader, r.AuxOff(li, j))
|
||||||
|
switch a.Type {
|
||||||
|
case goobj2.AuxGotype:
|
||||||
|
pp.gotype = l.resolve(r, a.Sym)
|
||||||
|
default:
|
||||||
|
log.Fatalf("internal error: cloneToExternal applied to %s symbol %s with non-gotype aux data %d", skind.String(), sname, a.Type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fix up the lookup tables if the symbol in question was
|
// Fix up the lookup tables if the symbol in question was
|
||||||
// present in the lookup tables. At the moment it only makes
|
// present in the lookup tables. At the moment it only makes
|
||||||
// sense to do this sort of clone/update for symbols that are
|
// sense to do this sort of clone/update for symbols that are
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue