]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: avoid name collision with DWARF .def suffix
authorIan Lance Taylor <iant@golang.org>
Fri, 3 Jun 2016 14:11:52 +0000 (07:11 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 3 Jun 2016 16:56:29 +0000 (16:56 +0000)
Adding a .def suffix for DWARF info collided with the DWARF info,
without the suffix, for a method named def. Change the suffix to ..def
instead.

Fixes #15926.

Change-Id: If1bf1bcb5dff1d7f7b79f78e3f7a3bbfcd2201bb
Reviewed-on: https://go-review.googlesource.com/23733
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/cmd/link/internal/ld/dwarf.go
test/fixedbugs/issue15926.go [new file with mode: 0644]

index 01747c543017a742608a42f6c1a938614fdac801..fa7105f62044dbf386ab876bc6058a615c833980 100644 (file)
@@ -529,7 +529,7 @@ func walktypedef(die *DWDie) *DWDie {
 }
 
 func walksymtypedef(s *LSym) *LSym {
-       if t := Linkrlookup(Ctxt, s.Name+".def", int(s.Version)); t != nil {
+       if t := Linkrlookup(Ctxt, s.Name+"..def", int(s.Version)); t != nil {
                return t
        }
        return s
@@ -819,7 +819,7 @@ func dotypedef(parent *DWDie, name string, def *DWDie) {
                Diag("dwarf: bad def in dotypedef")
        }
 
-       def.sym = Linklookup(Ctxt, def.sym.Name+".def", 0)
+       def.sym = Linklookup(Ctxt, def.sym.Name+"..def", 0)
        def.sym.Attr |= AttrHidden
        def.sym.Type = obj.SDWARFINFO
 
@@ -1021,7 +1021,7 @@ func newtype(gotype *LSym) *DWDie {
 }
 
 func nameFromDIESym(dwtype *LSym) string {
-       return strings.TrimSuffix(dwtype.Name[len(infoprefix):], ".def")
+       return strings.TrimSuffix(dwtype.Name[len(infoprefix):], "..def")
 }
 
 // Find or construct *T given T.
diff --git a/test/fixedbugs/issue15926.go b/test/fixedbugs/issue15926.go
new file mode 100644 (file)
index 0000000..76e25eb
--- /dev/null
@@ -0,0 +1,20 @@
+// build
+
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 15926: linker was adding .def to the end of symbols, causing
+// a name collision with a method actually named def.
+
+package main
+
+type S struct{}
+
+func (s S) def() {}
+
+var I = S.def
+
+func main() {
+    I(S{})
+}