[dev.link] cmd/internal/obj: handle content-addressable symbols with relocations

For content-addressable symbols with relocations, we build a
content hash based on its content and relocations. Depending on
the category of the referenced symbol, we choose different hash
algorithms such that the hash is globally consistent.

For now, we only support content-addressable symbols with
relocations when the current package's import path is known, so
that the symbol names are fully expanded. Otherwise, if the
referenced symbol is a named symbol whose name is not fully
expanded, the hash won't be globally consistent, and can cause
erroneous collisions. This is fine for now, as the deduplication
is just an optimization, not a requirement for correctness (until
we get to type descriptors).

Change-Id: I639e4e03dd749b5d71f0a55c2525926575b1ac30
Reviewed-on: https://go-review.googlesource.com/c/go/+/243142
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Zhang 2020-07-15 23:14:50 -04:00
parent 289c238a33
commit 526d99a49a
7 changed files with 166 additions and 11 deletions

View file

@ -41,6 +41,7 @@ func main() {
ctxt.Flag_dynlink = *flags.Dynlink
ctxt.Flag_shared = *flags.Shared || *flags.Dynlink
ctxt.IsAsm = true
ctxt.Pkgpath = *flags.Importpath
switch *flags.Spectre {
default:
log.Printf("unknown setting -spectre=%s", *flags.Spectre)
@ -97,7 +98,7 @@ func main() {
}
if ok && !*flags.SymABIs {
ctxt.NumberSyms()
obj.WriteObjFile(ctxt, buf, *flags.Importpath)
obj.WriteObjFile(ctxt, buf)
}
if !ok || diag {
if failedFile != "" {