summaryrefslogtreecommitdiffstats
path: root/misc/cgo/testshared/testdata
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:23:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:23:18 +0000
commit43a123c1ae6613b3efeed291fa552ecd909d3acf (patch)
treefd92518b7024bc74031f78a1cf9e454b65e73665 /misc/cgo/testshared/testdata
parentInitial commit. (diff)
downloadgolang-1.20-43a123c1ae6613b3efeed291fa552ecd909d3acf.tar.xz
golang-1.20-43a123c1ae6613b3efeed291fa552ecd909d3acf.zip
Adding upstream version 1.20.14.upstream/1.20.14upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'misc/cgo/testshared/testdata')
-rw-r--r--misc/cgo/testshared/testdata/dep2/dep2.go15
-rw-r--r--misc/cgo/testshared/testdata/dep3/dep3.go22
-rw-r--r--misc/cgo/testshared/testdata/depBase/asm.s10
-rw-r--r--misc/cgo/testshared/testdata/depBase/dep.go37
-rw-r--r--misc/cgo/testshared/testdata/depBase/gccgo.go9
-rw-r--r--misc/cgo/testshared/testdata/depBase/stubs.go9
-rw-r--r--misc/cgo/testshared/testdata/division/division.go17
-rw-r--r--misc/cgo/testshared/testdata/exe/exe.go45
-rw-r--r--misc/cgo/testshared/testdata/exe2/exe2.go8
-rw-r--r--misc/cgo/testshared/testdata/exe3/exe3.go7
-rw-r--r--misc/cgo/testshared/testdata/execgo/exe.go8
-rw-r--r--misc/cgo/testshared/testdata/explicit/explicit.go9
-rw-r--r--misc/cgo/testshared/testdata/gcdata/main/main.go37
-rw-r--r--misc/cgo/testshared/testdata/gcdata/p/p.go7
-rw-r--r--misc/cgo/testshared/testdata/global/main.go71
-rw-r--r--misc/cgo/testshared/testdata/globallib/global.go17
-rw-r--r--misc/cgo/testshared/testdata/iface/main.go17
-rw-r--r--misc/cgo/testshared/testdata/iface_a/a.go17
-rw-r--r--misc/cgo/testshared/testdata/iface_b/b.go17
-rw-r--r--misc/cgo/testshared/testdata/iface_i/i.go17
-rw-r--r--misc/cgo/testshared/testdata/implicit/implicit.go5
-rw-r--r--misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go10
-rw-r--r--misc/cgo/testshared/testdata/issue25065/a.go20
-rw-r--r--misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go11
-rw-r--r--misc/cgo/testshared/testdata/issue30768/x_test.go22
-rw-r--r--misc/cgo/testshared/testdata/issue39777/a/a.go9
-rw-r--r--misc/cgo/testshared/testdata/issue39777/b/b.go7
-rw-r--r--misc/cgo/testshared/testdata/issue44031/a/a.go9
-rw-r--r--misc/cgo/testshared/testdata/issue44031/b/b.go17
-rw-r--r--misc/cgo/testshared/testdata/issue44031/main/main.go20
-rw-r--r--misc/cgo/testshared/testdata/issue47837/a/a.go19
-rw-r--r--misc/cgo/testshared/testdata/issue47837/main/main.go14
-rw-r--r--misc/cgo/testshared/testdata/issue58966/main.go15
-rw-r--r--misc/cgo/testshared/testdata/trivial/trivial.go9
34 files changed, 583 insertions, 0 deletions
diff --git a/misc/cgo/testshared/testdata/dep2/dep2.go b/misc/cgo/testshared/testdata/dep2/dep2.go
new file mode 100644
index 0000000..94f38cf
--- /dev/null
+++ b/misc/cgo/testshared/testdata/dep2/dep2.go
@@ -0,0 +1,15 @@
+package dep2
+
+import "testshared/depBase"
+
+var W int = 1
+
+var hasProg depBase.HasProg
+
+type Dep2 struct {
+ depBase.Dep
+}
+
+func G() int {
+ return depBase.F() + 1
+}
diff --git a/misc/cgo/testshared/testdata/dep3/dep3.go b/misc/cgo/testshared/testdata/dep3/dep3.go
new file mode 100644
index 0000000..6b02ad2
--- /dev/null
+++ b/misc/cgo/testshared/testdata/dep3/dep3.go
@@ -0,0 +1,22 @@
+package dep3
+
+// The point of this test file is that it references a type from
+// depBase that is also referenced in dep2, but dep2 is loaded by the
+// linker before depBase (because it is earlier in the import list).
+// There was a bug in the linker where it would not correctly read out
+// the type data in this case and later crash.
+
+import (
+ "testshared/dep2"
+ "testshared/depBase"
+)
+
+type Dep3 struct {
+ dep depBase.Dep
+ dep2 dep2.Dep2
+}
+
+func D3() int {
+ var x Dep3
+ return x.dep.X + x.dep2.X
+}
diff --git a/misc/cgo/testshared/testdata/depBase/asm.s b/misc/cgo/testshared/testdata/depBase/asm.s
new file mode 100644
index 0000000..0f1111f
--- /dev/null
+++ b/misc/cgo/testshared/testdata/depBase/asm.s
@@ -0,0 +1,10 @@
+// Copyright 2014 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.
+
+// +build gc
+
+#include "textflag.h"
+
+TEXT ·ImplementedInAsm(SB),NOSPLIT,$0-0
+ RET
diff --git a/misc/cgo/testshared/testdata/depBase/dep.go b/misc/cgo/testshared/testdata/depBase/dep.go
new file mode 100644
index 0000000..e7cc7c8
--- /dev/null
+++ b/misc/cgo/testshared/testdata/depBase/dep.go
@@ -0,0 +1,37 @@
+// 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.
+
+package depBase
+
+import (
+ "os"
+ "reflect"
+)
+
+var SlicePtr interface{} = &[]int{}
+
+var V int = 1
+
+var HasMask []string = []string{"hi"}
+
+type HasProg struct {
+ array [1024]*byte
+}
+
+type Dep struct {
+ X int
+}
+
+func (d *Dep) Method() int {
+ // This code below causes various go.itab.* symbols to be generated in
+ // the shared library. Similar code in ../exe/exe.go results in
+ // exercising https://golang.org/issues/17594
+ reflect.TypeOf(os.Stdout).Elem()
+ return 10
+}
+
+func F() int {
+ defer func() {}()
+ return V
+}
diff --git a/misc/cgo/testshared/testdata/depBase/gccgo.go b/misc/cgo/testshared/testdata/depBase/gccgo.go
new file mode 100644
index 0000000..2b02a1e
--- /dev/null
+++ b/misc/cgo/testshared/testdata/depBase/gccgo.go
@@ -0,0 +1,9 @@
+// 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.
+
+// +build gccgo
+
+package depBase
+
+func ImplementedInAsm() {}
diff --git a/misc/cgo/testshared/testdata/depBase/stubs.go b/misc/cgo/testshared/testdata/depBase/stubs.go
new file mode 100644
index 0000000..c779538
--- /dev/null
+++ b/misc/cgo/testshared/testdata/depBase/stubs.go
@@ -0,0 +1,9 @@
+// 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.
+
+// +build gc
+
+package depBase
+
+func ImplementedInAsm()
diff --git a/misc/cgo/testshared/testdata/division/division.go b/misc/cgo/testshared/testdata/division/division.go
new file mode 100644
index 0000000..bb5fc98
--- /dev/null
+++ b/misc/cgo/testshared/testdata/division/division.go
@@ -0,0 +1,17 @@
+// Copyright 2017 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
+
+//go:noinline
+func div(x, y uint32) uint32 {
+ return x / y
+}
+
+func main() {
+ a := div(97, 11)
+ if a != 8 {
+ panic("FAIL")
+ }
+}
diff --git a/misc/cgo/testshared/testdata/exe/exe.go b/misc/cgo/testshared/testdata/exe/exe.go
new file mode 100644
index 0000000..ee95f97
--- /dev/null
+++ b/misc/cgo/testshared/testdata/exe/exe.go
@@ -0,0 +1,45 @@
+package main
+
+import (
+ "os"
+ "reflect"
+ "runtime"
+
+ "testshared/depBase"
+)
+
+// Having a function declared in the main package triggered
+// golang.org/issue/18250
+func DeclaredInMain() {
+}
+
+type C struct {
+}
+
+func F() *C {
+ return nil
+}
+
+var slicePtr interface{} = &[]int{}
+
+func main() {
+ defer depBase.ImplementedInAsm()
+ // This code below causes various go.itab.* symbols to be generated in
+ // the executable. Similar code in ../depBase/dep.go results in
+ // exercising https://golang.org/issues/17594
+ reflect.TypeOf(os.Stdout).Elem()
+ runtime.GC()
+ depBase.V = depBase.F() + 1
+
+ var c *C
+ if reflect.TypeOf(F).Out(0) != reflect.TypeOf(c) {
+ panic("bad reflection results, see golang.org/issue/18252")
+ }
+
+ sp := reflect.New(reflect.TypeOf(slicePtr).Elem())
+ s := sp.Interface()
+
+ if reflect.TypeOf(s) != reflect.TypeOf(slicePtr) {
+ panic("bad reflection results, see golang.org/issue/18729")
+ }
+}
diff --git a/misc/cgo/testshared/testdata/exe2/exe2.go b/misc/cgo/testshared/testdata/exe2/exe2.go
new file mode 100644
index 0000000..433f331
--- /dev/null
+++ b/misc/cgo/testshared/testdata/exe2/exe2.go
@@ -0,0 +1,8 @@
+package main
+
+import "testshared/dep2"
+
+func main() {
+ d := &dep2.Dep2{}
+ dep2.W = dep2.G() + 1 + d.Method()
+}
diff --git a/misc/cgo/testshared/testdata/exe3/exe3.go b/misc/cgo/testshared/testdata/exe3/exe3.go
new file mode 100644
index 0000000..533e3a9
--- /dev/null
+++ b/misc/cgo/testshared/testdata/exe3/exe3.go
@@ -0,0 +1,7 @@
+package main
+
+import "testshared/dep3"
+
+func main() {
+ dep3.D3()
+}
diff --git a/misc/cgo/testshared/testdata/execgo/exe.go b/misc/cgo/testshared/testdata/execgo/exe.go
new file mode 100644
index 0000000..0427be8
--- /dev/null
+++ b/misc/cgo/testshared/testdata/execgo/exe.go
@@ -0,0 +1,8 @@
+package main
+
+/*
+ */
+import "C"
+
+func main() {
+}
diff --git a/misc/cgo/testshared/testdata/explicit/explicit.go b/misc/cgo/testshared/testdata/explicit/explicit.go
new file mode 100644
index 0000000..af969fc
--- /dev/null
+++ b/misc/cgo/testshared/testdata/explicit/explicit.go
@@ -0,0 +1,9 @@
+package explicit
+
+import (
+ "testshared/implicit"
+)
+
+func E() int {
+ return implicit.I()
+}
diff --git a/misc/cgo/testshared/testdata/gcdata/main/main.go b/misc/cgo/testshared/testdata/gcdata/main/main.go
new file mode 100644
index 0000000..394862f
--- /dev/null
+++ b/misc/cgo/testshared/testdata/gcdata/main/main.go
@@ -0,0 +1,37 @@
+// Copyright 2020 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.
+
+// Test that GC data is generated correctly for global
+// variables with types defined in a shared library.
+// See issue 39927.
+
+// This test run under GODEBUG=clobberfree=1. The check
+// *x[i] == 12345 depends on this debug mode to clobber
+// the value if the object is freed prematurely.
+
+package main
+
+import (
+ "fmt"
+ "runtime"
+ "testshared/gcdata/p"
+)
+
+var x p.T
+
+func main() {
+ for i := range x {
+ x[i] = new(int)
+ *x[i] = 12345
+ }
+ runtime.GC()
+ runtime.GC()
+ runtime.GC()
+ for i := range x {
+ if *x[i] != 12345 {
+ fmt.Printf("x[%d] == %d, want 12345\n", i, *x[i])
+ panic("FAIL")
+ }
+ }
+}
diff --git a/misc/cgo/testshared/testdata/gcdata/p/p.go b/misc/cgo/testshared/testdata/gcdata/p/p.go
new file mode 100644
index 0000000..1fee754
--- /dev/null
+++ b/misc/cgo/testshared/testdata/gcdata/p/p.go
@@ -0,0 +1,7 @@
+// Copyright 2020 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 p
+
+type T [10]*int
diff --git a/misc/cgo/testshared/testdata/global/main.go b/misc/cgo/testshared/testdata/global/main.go
new file mode 100644
index 0000000..f43e7c3
--- /dev/null
+++ b/misc/cgo/testshared/testdata/global/main.go
@@ -0,0 +1,71 @@
+// Copyright 2017 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 (
+ "testshared/globallib"
+)
+
+//go:noinline
+func testLoop() {
+ for i, s := range globallib.Data {
+ if s != int64(i) {
+ panic("testLoop: mismatch")
+ }
+ }
+}
+
+//go:noinline
+func ptrData() *[1<<20 + 10]int64 {
+ return &globallib.Data
+}
+
+//go:noinline
+func testMediumOffset() {
+ for i, s := range globallib.Data[1<<16-2:] {
+ if s != int64(i)+1<<16-2 {
+ panic("testMediumOffset: index mismatch")
+ }
+ }
+
+ x := globallib.Data[1<<16-1]
+ if x != 1<<16-1 {
+ panic("testMediumOffset: direct mismatch")
+ }
+
+ y := &globallib.Data[1<<16-3]
+ if y != &ptrData()[1<<16-3] {
+ panic("testMediumOffset: address mismatch")
+ }
+}
+
+//go:noinline
+func testLargeOffset() {
+ for i, s := range globallib.Data[1<<20:] {
+ if s != int64(i)+1<<20 {
+ panic("testLargeOffset: index mismatch")
+ }
+ }
+
+ x := globallib.Data[1<<20+1]
+ if x != 1<<20+1 {
+ panic("testLargeOffset: direct mismatch")
+ }
+
+ y := &globallib.Data[1<<20+2]
+ if y != &ptrData()[1<<20+2] {
+ panic("testLargeOffset: address mismatch")
+ }
+}
+
+func main() {
+ testLoop()
+
+ // SSA rules commonly merge offsets into addresses. These
+ // tests access global data in different ways to try
+ // and exercise different SSA rules.
+ testMediumOffset()
+ testLargeOffset()
+}
diff --git a/misc/cgo/testshared/testdata/globallib/global.go b/misc/cgo/testshared/testdata/globallib/global.go
new file mode 100644
index 0000000..b4372a2
--- /dev/null
+++ b/misc/cgo/testshared/testdata/globallib/global.go
@@ -0,0 +1,17 @@
+// Copyright 2017 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 globallib
+
+// Data is large enough to that offsets into it do not fit into
+// 16-bit or 20-bit immediates. Ideally we'd also try and overrun
+// 32-bit immediates, but that requires the test machine to have
+// too much memory.
+var Data [1<<20 + 10]int64
+
+func init() {
+ for i := range Data {
+ Data[i] = int64(i)
+ }
+}
diff --git a/misc/cgo/testshared/testdata/iface/main.go b/misc/cgo/testshared/testdata/iface/main.go
new file mode 100644
index 0000000..d26ebbc
--- /dev/null
+++ b/misc/cgo/testshared/testdata/iface/main.go
@@ -0,0 +1,17 @@
+// Copyright 2017 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 "testshared/iface_a"
+import "testshared/iface_b"
+
+func main() {
+ if iface_a.F() != iface_b.F() {
+ panic("empty interfaces not equal")
+ }
+ if iface_a.G() != iface_b.G() {
+ panic("non-empty interfaces not equal")
+ }
+}
diff --git a/misc/cgo/testshared/testdata/iface_a/a.go b/misc/cgo/testshared/testdata/iface_a/a.go
new file mode 100644
index 0000000..e2cef1e
--- /dev/null
+++ b/misc/cgo/testshared/testdata/iface_a/a.go
@@ -0,0 +1,17 @@
+// Copyright 2017 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 iface_a
+
+import "testshared/iface_i"
+
+//go:noinline
+func F() interface{} {
+ return (*iface_i.T)(nil)
+}
+
+//go:noinline
+func G() iface_i.I {
+ return (*iface_i.T)(nil)
+}
diff --git a/misc/cgo/testshared/testdata/iface_b/b.go b/misc/cgo/testshared/testdata/iface_b/b.go
new file mode 100644
index 0000000..dd3e027
--- /dev/null
+++ b/misc/cgo/testshared/testdata/iface_b/b.go
@@ -0,0 +1,17 @@
+// Copyright 2017 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 iface_b
+
+import "testshared/iface_i"
+
+//go:noinline
+func F() interface{} {
+ return (*iface_i.T)(nil)
+}
+
+//go:noinline
+func G() iface_i.I {
+ return (*iface_i.T)(nil)
+}
diff --git a/misc/cgo/testshared/testdata/iface_i/i.go b/misc/cgo/testshared/testdata/iface_i/i.go
new file mode 100644
index 0000000..31c8038
--- /dev/null
+++ b/misc/cgo/testshared/testdata/iface_i/i.go
@@ -0,0 +1,17 @@
+// Copyright 2017 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 iface_i
+
+type I interface {
+ M()
+}
+
+type T struct {
+}
+
+func (t *T) M() {
+}
+
+// *T implements I
diff --git a/misc/cgo/testshared/testdata/implicit/implicit.go b/misc/cgo/testshared/testdata/implicit/implicit.go
new file mode 100644
index 0000000..5360188
--- /dev/null
+++ b/misc/cgo/testshared/testdata/implicit/implicit.go
@@ -0,0 +1,5 @@
+package implicit
+
+func I() int {
+ return 42
+}
diff --git a/misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go b/misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go
new file mode 100644
index 0000000..4d42967
--- /dev/null
+++ b/misc/cgo/testshared/testdata/implicitcmd/implicitcmd.go
@@ -0,0 +1,10 @@
+package main
+
+import (
+ "testshared/explicit"
+ "testshared/implicit"
+)
+
+func main() {
+ println(implicit.I() + explicit.E())
+}
diff --git a/misc/cgo/testshared/testdata/issue25065/a.go b/misc/cgo/testshared/testdata/issue25065/a.go
new file mode 100644
index 0000000..979350f
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue25065/a.go
@@ -0,0 +1,20 @@
+// Copyright 2018 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 issue25065 has a type with a method that is
+// 1) referenced in a method expression
+// 2) not called
+// 3) not converted to an interface
+// 4) is a value method but the reference is to the pointer method
+// These cases avoid the call to makefuncsym from typecheckfunc, but we
+// still need to call makefuncsym somehow or the symbol will not be defined.
+package issue25065
+
+type T int
+
+func (t T) M() {}
+
+func F() func(*T) {
+ return (*T).M
+}
diff --git a/misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go b/misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go
new file mode 100644
index 0000000..9e45ebe
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue30768/issue30768lib/lib.go
@@ -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 issue30768lib
+
+// S is a struct that requires a generated hash function.
+type S struct {
+ A string
+ B int
+}
diff --git a/misc/cgo/testshared/testdata/issue30768/x_test.go b/misc/cgo/testshared/testdata/issue30768/x_test.go
new file mode 100644
index 0000000..1bbd139
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue30768/x_test.go
@@ -0,0 +1,22 @@
+// 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 issue30768_test
+
+import (
+ "testing"
+
+ "testshared/issue30768/issue30768lib"
+)
+
+type s struct {
+ s issue30768lib.S
+}
+
+func Test30768(t *testing.T) {
+ // Calling t.Log will convert S to an empty interface,
+ // which will force a reference to the generated hash function,
+ // defined in the shared library.
+ t.Log(s{})
+}
diff --git a/misc/cgo/testshared/testdata/issue39777/a/a.go b/misc/cgo/testshared/testdata/issue39777/a/a.go
new file mode 100644
index 0000000..c7bf835
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue39777/a/a.go
@@ -0,0 +1,9 @@
+// Copyright 2020 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 "testshared/issue39777/b"
+
+func F() { b.F() }
diff --git a/misc/cgo/testshared/testdata/issue39777/b/b.go b/misc/cgo/testshared/testdata/issue39777/b/b.go
new file mode 100644
index 0000000..4e68196
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue39777/b/b.go
@@ -0,0 +1,7 @@
+// Copyright 2020 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
+
+func F() {}
diff --git a/misc/cgo/testshared/testdata/issue44031/a/a.go b/misc/cgo/testshared/testdata/issue44031/a/a.go
new file mode 100644
index 0000000..48827e6
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue44031/a/a.go
@@ -0,0 +1,9 @@
+// Copyright 2021 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
+
+type ATypeWithALoooooongName interface { // a long name, so the type descriptor symbol name is mangled
+ M()
+}
diff --git a/misc/cgo/testshared/testdata/issue44031/b/b.go b/misc/cgo/testshared/testdata/issue44031/b/b.go
new file mode 100644
index 0000000..ad3ebec
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue44031/b/b.go
@@ -0,0 +1,17 @@
+// Copyright 2021 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 "testshared/issue44031/a"
+
+type T int
+
+func (T) M() {}
+
+var i = a.ATypeWithALoooooongName(T(0))
+
+func F() {
+ i.M()
+}
diff --git a/misc/cgo/testshared/testdata/issue44031/main/main.go b/misc/cgo/testshared/testdata/issue44031/main/main.go
new file mode 100644
index 0000000..47f2e3a
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue44031/main/main.go
@@ -0,0 +1,20 @@
+// Copyright 2021 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 "testshared/issue44031/b"
+
+type t int
+
+func (t) m() {}
+
+type i interface{ m() } // test that unexported method is correctly marked
+
+var v interface{} = t(0)
+
+func main() {
+ b.F()
+ v.(i).m()
+}
diff --git a/misc/cgo/testshared/testdata/issue47837/a/a.go b/misc/cgo/testshared/testdata/issue47837/a/a.go
new file mode 100644
index 0000000..68588ed
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue47837/a/a.go
@@ -0,0 +1,19 @@
+// Copyright 2021 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
+
+type A interface {
+ M()
+}
+
+//go:noinline
+func TheFuncWithArgA(a A) {
+ a.M()
+}
+
+type ImplA struct{}
+
+//go:noinline
+func (A *ImplA) M() {}
diff --git a/misc/cgo/testshared/testdata/issue47837/main/main.go b/misc/cgo/testshared/testdata/issue47837/main/main.go
new file mode 100644
index 0000000..77c6f34
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue47837/main/main.go
@@ -0,0 +1,14 @@
+// Copyright 2021 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 (
+ "testshared/issue47837/a"
+)
+
+func main() {
+ var vara a.ImplA
+ a.TheFuncWithArgA(&vara)
+}
diff --git a/misc/cgo/testshared/testdata/issue58966/main.go b/misc/cgo/testshared/testdata/issue58966/main.go
new file mode 100644
index 0000000..2d923c3
--- /dev/null
+++ b/misc/cgo/testshared/testdata/issue58966/main.go
@@ -0,0 +1,15 @@
+// Copyright 2023 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 "crypto/elliptic"
+
+var curve elliptic.Curve
+
+func main() {
+ switch curve {
+ case elliptic.P224():
+ }
+}
diff --git a/misc/cgo/testshared/testdata/trivial/trivial.go b/misc/cgo/testshared/testdata/trivial/trivial.go
new file mode 100644
index 0000000..6ade47c
--- /dev/null
+++ b/misc/cgo/testshared/testdata/trivial/trivial.go
@@ -0,0 +1,9 @@
+package main
+
+func main() {
+ // This is enough to make sure that the executable references
+ // a type descriptor, which was the cause of
+ // https://golang.org/issue/25970.
+ c := make(chan int)
+ _ = c
+}