From: Jeremy Faller Date: Wed, 30 Sep 2020 21:57:14 +0000 (-0400) Subject: [dev.link] Merge branch 'master' into dev.link X-Git-Tag: go1.16beta1~877^2^2 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=91e4d2d57bc341dd82c98247117114c851380aef;p=gostls13.git [dev.link] Merge branch 'master' into dev.link 2 conflicts, that make sense. src/cmd/internal/obj/objfile.go src/cmd/link/internal/loader/loader.go Change-Id: Ib224e2d248cb568fa1e888af79dd908b2f5e05ff --- 91e4d2d57bc341dd82c98247117114c851380aef diff --cc src/cmd/internal/obj/objfile.go index a2bbdff24e,186016c970..fa60c9ad6d --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@@ -376,19 -372,13 +376,26 @@@ func contentHash64(s *LSym) goobj.Hash6 // hashed symbols. func (w *writer) contentHash(s *LSym) goobj.HashType { h := sha1.New() + var tmp [14]byte + + // Include the size of the symbol in the hash. + // This preserves the length of symbols, preventing the following two symbols + // from hashing the same: + // + // [2]int{1,2} ≠ [10]int{1,2,0,0,0...} + // + // In this case, if the smaller symbol is alive, the larger is not kept unless + // needed. + binary.LittleEndian.PutUint64(tmp[:8], uint64(s.Size)) + h.Write(tmp[:8]) + + // Don't dedup type symbols with others, as they are in a different + // section. + if strings.HasPrefix(s.Name, "type.") { + h.Write([]byte{'T'}) + } else { + h.Write([]byte{0}) + } // The compiler trims trailing zeros _sometimes_. We just do // it always. h.Write(bytes.TrimRight(s.P, "\x00"))