From 77680a064491dd54bd61ef0663276d6f64f66153 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Mon, 21 Mar 2022 15:46:32 -0400 Subject: [PATCH] cmd/link: simplify content hashed symbol handling Symbol's content hash used to depend on package path expansion in symbol names, so we have special logic handling hashed symbols when path expansion is needed. As we required -p in the compiler the symbol names are now fully expanded. Remove that logic. Change-Id: I888574f63ea3789455d96468a6abd500e0958230 Reviewed-on: https://go-review.googlesource.com/c/go/+/394218 Trust: Cherry Mui Reviewed-by: Than McIntosh Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot --- src/cmd/link/internal/loader/loader.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go index 6f2d41aa78..d46aa41181 100644 --- a/src/cmd/link/internal/loader/loader.go +++ b/src/cmd/link/internal/loader/loader.go @@ -261,8 +261,6 @@ 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 @@ -361,7 +359,7 @@ func (l *Loader) addObj(pkg string, r *oReader) Sym { l.start[r] = i l.objs = append(l.objs, objIdx{r, i}) if r.NeedNameExpansion() && !r.FromAssembly() { - l.hasUnknownPkgPath = true + panic("object compiled without -p") } return i } @@ -2126,16 +2124,6 @@ func (st *loadState) 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()) -- 2.50.0