mirror of
https://github.com/golang/go
synced 2024-11-07 05:56:18 -07:00
[dev.link] cmd/link: add dupok symbols resolved to another package to textp
When a dupok symbol is resolved to another package, we still need to record its presence in the current package, as the trampoline pass expects packages are laid out in dependency order. At the point after deadcode where we populate symbol contents for reachable symbols (add relocations and read symbol data), make a note of the dupok text symbols for each package. Later in addToTextp we will visit packages in dependency order, process the dup text symbol list for each package and select a final lib for each dup text symbol. Change-Id: Ib885e0a7e2343229d853aa629e3e337111df6011 Reviewed-on: https://go-review.googlesource.com/c/go/+/200797 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
6ba3ae9ca5
commit
5fec788239
@ -559,20 +559,36 @@ func loadObjFull(l *Loader, r *oReader) {
|
||||
|
||||
pcdataBase := r.PcdataBase()
|
||||
for i, n := 0, r.NSym()+r.NNonpkgdef(); i < n; i++ {
|
||||
s := l.Syms[istart+Sym(i)]
|
||||
if s == nil || s.Name == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
osym := goobj2.Sym{}
|
||||
osym.Read(r.Reader, r.SymOff(i))
|
||||
name := strings.Replace(osym.Name, "\"\".", r.pkgprefix, -1)
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
ver := abiToVer(osym.ABI, r.version)
|
||||
dupok := osym.Flag&goobj2.SymFlagDupok != 0
|
||||
if dupsym := l.symsByName[nameVer{name, ver}]; dupsym != istart+Sym(i) {
|
||||
if dupok && l.Reachable.Has(dupsym) {
|
||||
// A dupok symbol is resolved to another package. We still need
|
||||
// to record its presence in the current package, as the trampoline
|
||||
// pass expects packages are laid out in dependency order.
|
||||
s := l.Syms[dupsym]
|
||||
if s.Type == sym.STEXT {
|
||||
lib.DupTextSyms = append(lib.DupTextSyms, s)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
s := l.Syms[istart+Sym(i)]
|
||||
if s == nil {
|
||||
continue
|
||||
}
|
||||
if s.Name != name { // Sanity check. We can remove it in the final version.
|
||||
fmt.Println("name mismatch:", lib, i, s.Name, name)
|
||||
panic("name mismatch")
|
||||
}
|
||||
|
||||
dupok := osym.Flag&goobj2.SymFlagDupok != 0
|
||||
local := osym.Flag&goobj2.SymFlagLocal != 0
|
||||
makeTypelink := osym.Flag&goobj2.SymFlagTypelink != 0
|
||||
size := osym.Siz
|
||||
|
Loading…
Reference in New Issue
Block a user