mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/compile, cmd/link: make itab symbols content-addressable
Extend the content-addressable symbol mechanism to itab symbols. Itab symbols require global uniqueness (as at run time we compare pointers), so it needs to be reliably deduplicated. Currently the content hash depends on symbol name expansion, so we can only do this when all Go packages are built with know package paths. Fall back to checking names if any Go package is built with unknown package path. Change-Id: Icf5e8873755050c20e5fc6549f6de1c883254c89 Reviewed-on: https://go-review.googlesource.com/c/go/+/245719 Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
parent
69748f0ce4
commit
cecb7a1cf3
3 changed files with 22 additions and 3 deletions
|
|
@ -277,6 +277,8 @@ type Loader struct {
|
|||
|
||||
flags uint32
|
||||
|
||||
hasUnknownPkgPath bool // if any Go object has unknown package path
|
||||
|
||||
strictDupMsgs int // number of strict-dup warning/errors, when FlagStrictDups is enabled
|
||||
|
||||
elfsetstring elfsetstringFunc
|
||||
|
|
@ -378,6 +380,9 @@ func (l *Loader) addObj(pkg string, r *oReader) Sym {
|
|||
i := Sym(len(l.objSyms))
|
||||
l.start[r] = i
|
||||
l.objs = append(l.objs, objIdx{r, i})
|
||||
if r.NeedNameExpansion() && !r.FromAssembly() {
|
||||
l.hasUnknownPkgPath = true
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
|
|
@ -2086,6 +2091,16 @@ func (l *Loader) preloadSyms(r *oReader, kind int) {
|
|||
case hashedDef:
|
||||
start = uint32(r.ndef + r.nhashed64def)
|
||||
end = uint32(r.ndef + r.nhashed64def + r.nhasheddef)
|
||||
if l.hasUnknownPkgPath {
|
||||
// The content hash depends on symbol name expansion. If any package is
|
||||
// built without fully expanded names, the content hash is unreliable.
|
||||
// Treat them as named symbols.
|
||||
// This is rare.
|
||||
// (We don't need to do this for hashed64Def case, as there the hash
|
||||
// function is simply the identity function, which doesn't depend on
|
||||
// name expansion.)
|
||||
kind = nonPkgDef
|
||||
}
|
||||
case nonPkgDef:
|
||||
start = uint32(r.ndef + r.nhashed64def + r.nhasheddef)
|
||||
end = uint32(r.ndef + r.nhashed64def + r.nhasheddef + r.NNonpkgdef())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue