]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: don't dedup symbols in WriteObjFile
authorAustin Clements <austin@google.com>
Mon, 29 Oct 2018 22:27:51 +0000 (18:27 -0400)
committerAustin Clements <austin@google.com>
Sat, 3 Nov 2018 15:12:58 +0000 (15:12 +0000)
Currently, WriteObjFile deduplicates symbols by name. This is a
strange and unexpected place to do this. But, worse, there's no
checking that it's reasonable to deduplicate two symbols, so this
makes it incredibly easy to mask errors involving duplicate symbols.
Dealing with duplicate symbols is better left to the linker. We're
also about to introduce multiple symbols with the same name but
different ABIs/versions, which would make this deduplication more
complicated. We just removed the only part of the compiler that
actually depended on this behavior.

This CL removes symbol deduplication from WriteObjFile, since it is no
longer needed.

For #27539.

Change-Id: I650c550e46e83f95c67cb6c6646f9b2f7f10df30
Reviewed-on: https://go-review.googlesource.com/c/146558
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/obj.go
src/cmd/internal/obj/objfile.go

index e3c8e07ffa71aef6278c5a73126c264545fb4cdc..5630e12ace7d01fed57a8770db43695aa9e34ecb 100644 (file)
@@ -273,10 +273,6 @@ func dumpglobls() {
 }
 
 // addGCLocals adds gcargs, gclocals, gcregs, and stack object symbols to Ctxt.Data.
-// It takes care not to add any duplicates.
-// Though the object file format handles duplicates efficiently,
-// storing only a single copy of the data,
-// failure to remove these duplicates adds a few percent to object file size.
 //
 // This is done during the sequential phase after compilation, since
 // global symbols can't be declared during parallel compilation.
index b6cfec3b3e6f5f0500f341cedd33c6d5b5c646d0..3c72f543ccb3707e18e86192c11599917e625dd6 100644 (file)
@@ -25,12 +25,6 @@ type objWriter struct {
        // Temporary buffer for zigzag int writing.
        varintbuf [10]uint8
 
-       // Provide the index of a symbol reference by symbol name.
-       // One map for versioned symbols and one for unversioned symbols.
-       // Used for deduplicating the symbol reference list.
-       refIdx  map[string]int
-       vrefIdx map[string]int
-
        // Number of objects written of each type.
        nRefs     int
        nData     int
@@ -79,10 +73,8 @@ func (w *objWriter) writeLengths() {
 
 func newObjWriter(ctxt *Link, b *bufio.Writer) *objWriter {
        return &objWriter{
-               ctxt:    ctxt,
-               wr:      b,
-               vrefIdx: make(map[string]int),
-               refIdx:  make(map[string]int),
+               ctxt: ctxt,
+               wr:   b,
        }
 }
 
@@ -157,17 +149,6 @@ func (w *objWriter) writeRef(s *LSym, isPath bool) {
        if s == nil || s.RefIdx != 0 {
                return
        }
-       var m map[string]int
-       if !s.Static() {
-               m = w.refIdx
-       } else {
-               m = w.vrefIdx
-       }
-
-       if idx := m[s.Name]; idx != 0 {
-               s.RefIdx = idx
-               return
-       }
        w.wr.WriteByte(symPrefix)
        if isPath {
                w.writeString(filepath.ToSlash(s.Name))
@@ -178,7 +159,6 @@ func (w *objWriter) writeRef(s *LSym, isPath bool) {
        w.writeBool(s.Static())
        w.nRefs++
        s.RefIdx = w.nRefs
-       m[s.Name] = w.nRefs
 }
 
 func (w *objWriter) writeRefs(s *LSym) {