]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: propagate gotype symbol info in cloneToExternal
authorThan McIntosh <thanm@google.com>
Tue, 7 Jan 2020 01:37:50 +0000 (20:37 -0500)
committerThan McIntosh <thanm@google.com>
Thu, 9 Jan 2020 20:08:31 +0000 (20:08 +0000)
This patch fixes a problem with the loader's cloneToExternal method,
specifically that the new external clone created did not get
the proper Gotype value from its orginal symbol.

Change-Id: I9978140d285104d407bf55649fb6ed94959933f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/213639
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/loader/loader.go

index 7899a23caf70cf4d6221a426b46d4a1b511bd63e..2cf4dd02ce1ee698292ced6d135a02d8e61a576c 100644 (file)
@@ -225,6 +225,7 @@ type extSymPayload struct {
        size   int64
        ver    int
        kind   sym.SymKind
+       gotype Sym // Gotype (0 if not present)
        relocs []Reloc
        data   []byte
 }
@@ -1524,6 +1525,9 @@ func (l *Loader) LoadFull(arch *sys.Arch, syms *sym.Symbols) {
                s.Type = pp.kind
                s.Size = pp.size
                s.Value = l.SymValue(i)
+               if pp.gotype != 0 {
+                       s.Gotype = l.Syms[pp.gotype]
+               }
 
                // Copy relocations
                batch := l.relocBatch
@@ -1823,6 +1827,20 @@ func (l *Loader) cloneToExternal(symIdx Sym) Sym {
                }
        }
 
+       // If we're overriding a data symbol, collect the associated
+       // Gotype, so as to propagate it to the new symbol.
+       naux := r.NAux(li)
+       for j := 0; j < naux; j++ {
+               a := goobj2.Aux{}
+               a.Read(r.Reader, r.AuxOff(li, j))
+               switch a.Type {
+               case goobj2.AuxGotype:
+                       pp.gotype = l.resolve(r, a.Sym)
+               default:
+                       log.Fatalf("internal error: cloneToExternal applied to %s symbol %s with non-gotype aux data %d", skind.String(), sname, a.Type)
+               }
+       }
+
        // Fix up the lookup tables if the symbol in question was
        // present in the lookup tables. At the moment it only makes
        // sense to do this sort of clone/update for symbols that are