]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/link: simplify content hashed symbol handling
authorCherry Mui <cherryyz@google.com>
Mon, 21 Mar 2022 19:46:32 +0000 (15:46 -0400)
committerCherry Mui <cherryyz@google.com>
Tue, 22 Mar 2022 19:39:12 +0000 (19:39 +0000)
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 <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/link/internal/loader/loader.go

index 6f2d41aa789ec1d4782c3a1547ac8337a011b8c8..d46aa411815be8489a11c17627d28614b9047c39 100644 (file)
@@ -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())