mirror of
https://github.com/golang/go
synced 2024-11-11 19:51:37 -07:00
cmd/compile: use correct package name for stack object symbol
Stack object generation code was always using the local package name for its symbol. Normally that doesn't matter, as we usually only compile functions in the local package. But for wrappers, the compiler generates functions which live in other packages. When there are two other packages with identical functions to wrap, the same name appears twice, and the compiler goes boom. Fixes #31252 Change-Id: I7026eebabe562cb159b8b6046cf656afd336ba25 Reviewed-on: https://go-review.googlesource.com/c/go/+/171464 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
d1f43ccef7
commit
43001a0dc9
@ -287,7 +287,7 @@ func addGCLocals() {
|
||||
}
|
||||
}
|
||||
if x := s.Func.StackObjects; x != nil {
|
||||
ggloblsym(x, int32(len(x.P)), obj.RODATA|obj.LOCAL)
|
||||
ggloblsym(x, int32(len(x.P)), obj.RODATA|obj.DUPOK)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ func compile(fn *Node) {
|
||||
// Also make sure we allocate a linker symbol
|
||||
// for the stack object data, for the same reason.
|
||||
if fn.Func.lsym.Func.StackObjects == nil {
|
||||
fn.Func.lsym.Func.StackObjects = lookup(fmt.Sprintf("%s.stkobj", fn.funcname())).Linksym()
|
||||
fn.Func.lsym.Func.StackObjects = Ctxt.Lookup(fn.Func.lsym.Name + ".stkobj")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
13
test/fixedbugs/issue31252.dir/a.go
Normal file
13
test/fixedbugs/issue31252.dir/a.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2019 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.
|
||||
|
||||
package a
|
||||
|
||||
import "fmt"
|
||||
|
||||
type IndexController struct{}
|
||||
|
||||
func (this *IndexController) Index(m *string) {
|
||||
fmt.Println(m)
|
||||
}
|
13
test/fixedbugs/issue31252.dir/b.go
Normal file
13
test/fixedbugs/issue31252.dir/b.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2019 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.
|
||||
|
||||
package b
|
||||
|
||||
import "fmt"
|
||||
|
||||
type IndexController struct{}
|
||||
|
||||
func (this *IndexController) Index(m *string) {
|
||||
fmt.Println(m)
|
||||
}
|
26
test/fixedbugs/issue31252.dir/c.go
Normal file
26
test/fixedbugs/issue31252.dir/c.go
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2019 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.
|
||||
|
||||
package c
|
||||
|
||||
import (
|
||||
"a"
|
||||
"b"
|
||||
)
|
||||
|
||||
type HandlerFunc func(*string)
|
||||
|
||||
func RouterInit() {
|
||||
//home API
|
||||
homeIndex := &a.IndexController{}
|
||||
GET("/home/index/index", homeIndex.Index)
|
||||
//admin API
|
||||
adminIndex := &b.IndexController{}
|
||||
GET("/admin/index/index", adminIndex.Index)
|
||||
return
|
||||
}
|
||||
|
||||
func GET(path string, handlers ...HandlerFunc) {
|
||||
return
|
||||
}
|
11
test/fixedbugs/issue31252.dir/main.go
Normal file
11
test/fixedbugs/issue31252.dir/main.go
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2019 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.
|
||||
|
||||
package main
|
||||
|
||||
import "c"
|
||||
|
||||
func main() {
|
||||
c.RouterInit()
|
||||
}
|
7
test/fixedbugs/issue31252.go
Normal file
7
test/fixedbugs/issue31252.go
Normal file
@ -0,0 +1,7 @@
|
||||
// compiledir
|
||||
|
||||
// Copyright 2019 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.
|
||||
|
||||
package ignored
|
Loading…
Reference in New Issue
Block a user