These symbols are de-duplicated in the linker but the compiler generates quite
many duplicates too: 2425 of 13769 total symbols for runtime.a for example.
De-duplicating them in the compiler saves the linker a bit of work.
Fixes #14983
Change-Id: I5f18e5f9743563c795aad8f0a22d17a7ed147711
Reviewed-on: https://go-review.googlesource.com/22293
Reviewed-by: David Crawshaw <crawshaw@golang.org>
"cmd/compile/internal/ssa"
"cmd/internal/obj"
"cmd/internal/sys"
- "crypto/md5"
"fmt"
"sort"
"strings"
}
}
-func gcsymdup(s *Sym) {
- ls := Linksym(s)
- if len(ls.R) > 0 {
- Fatalf("cannot rosymdup %s with relocations", ls.Name)
- }
- ls.Name = fmt.Sprintf("gclocals·%x", md5.Sum(ls.P))
- ls.Dupok = true
-}
-
func emitptrargsmap() {
if Curfn.Func.Nname.Sym.Name == "_" {
return
// Emit garbage collection symbols.
liveness(Curfn, ptxt, gcargs, gclocals)
- gcsymdup(gcargs)
- gcsymdup(gclocals)
-
Thearch.Defframe(ptxt)
if Debug['f'] != 0 {
import (
"cmd/internal/obj"
"cmd/internal/sys"
+ "crypto/md5"
"fmt"
"sort"
"strings"
}
duint32(sym, 0, uint32(i)) // number of bitmaps
- ggloblsym(sym, int32(off), obj.RODATA)
+ ls := Linksym(sym)
+ ls.Name = fmt.Sprintf("gclocals·%x", md5.Sum(ls.P))
+ ls.Dupok = true
+ sv := obj.SymVer{ls.Name, 0}
+ ls2, ok := Ctxt.Hash[sv]
+ if ok {
+ sym.Lsym = ls2
+ } else {
+ Ctxt.Hash[sv] = ls
+ ggloblsym(sym, int32(off), obj.RODATA)
+ }
}
func printprog(p *obj.Prog) {
// Generate gc bitmaps.
liveness(Curfn, ptxt, gcargs, gclocals)
- gcsymdup(gcargs)
- gcsymdup(gclocals)
// Add frame prologue. Zero ambiguously live variables.
Thearch.Defframe(ptxt)